tensor-sensor
27 строк · 674.0 Байт
1# Test for https://github.com/parrt/tensor-sensor/issues/18
2# Nested clarify's and all catch exception
3
4import tsensor
5import numpy as np
6
7def f():
8np.ones(1) @ np.ones(2)
9
10def A():
11with tsensor.clarify():
12f()
13
14def B():
15with tsensor.clarify():
16A()
17
18def test_nested():
19msg = ""
20try:
21B()
22except BaseException as e:
23msg = e.args[0]
24
25expected = "matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 1)\n"+\
26"Cause: @ on tensor operand np.ones(1) w/shape (1,) and operand np.ones(2) w/shape (2,)"
27assert msg==expected
28