图片解析应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

621 lines
20 KiB

  1. """
  2. Important note on tests in this module - the Aesara printing functions use a
  3. global cache by default, which means that tests using it will modify global
  4. state and thus not be independent from each other. Instead of using the "cache"
  5. keyword argument each time, this module uses the aesara_code_ and
  6. aesara_function_ functions defined below which default to using a new, empty
  7. cache instead.
  8. """
  9. import logging
  10. from sympy.external import import_module
  11. from sympy.testing.pytest import raises, SKIP
  12. aesaralogger = logging.getLogger('aesara.configdefaults')
  13. aesaralogger.setLevel(logging.CRITICAL)
  14. aesara = import_module('aesara')
  15. aesaralogger.setLevel(logging.WARNING)
  16. if aesara:
  17. import numpy as np
  18. aet = aesara.tensor
  19. from aesara.scalar.basic import Scalar
  20. from aesara.graph.basic import Variable
  21. from aesara.tensor.var import TensorVariable
  22. from aesara.tensor.elemwise import Elemwise, DimShuffle
  23. from aesara.tensor.math import Dot
  24. xt, yt, zt = [aet.scalar(name, 'floatX') for name in 'xyz']
  25. Xt, Yt, Zt = [aet.tensor('floatX', (False, False), name=n) for n in 'XYZ']
  26. else:
  27. #bin/test will not execute any tests now
  28. disabled = True
  29. import sympy as sy
  30. from sympy.core.singleton import S
  31. from sympy.abc import x, y, z, t
  32. from sympy.printing.aesaracode import (aesara_code, dim_handling,
  33. aesara_function)
  34. # Default set of matrix symbols for testing - make square so we can both
  35. # multiply and perform elementwise operations between them.
  36. X, Y, Z = [sy.MatrixSymbol(n, 4, 4) for n in 'XYZ']
  37. # For testing AppliedUndef
  38. f_t = sy.Function('f')(t)
  39. def aesara_code_(expr, **kwargs):
  40. """ Wrapper for aesara_code that uses a new, empty cache by default. """
  41. kwargs.setdefault('cache', {})
  42. return aesara_code(expr, **kwargs)
  43. def aesara_function_(inputs, outputs, **kwargs):
  44. """ Wrapper for aesara_function that uses a new, empty cache by default. """
  45. kwargs.setdefault('cache', {})
  46. return aesara_function(inputs, outputs, **kwargs)
  47. def fgraph_of(*exprs):
  48. """ Transform SymPy expressions into Aesara Computation.
  49. Parameters
  50. ==========
  51. exprs
  52. SymPy expressions
  53. Returns
  54. =======
  55. aesara.graph.fg.FunctionGraph
  56. """
  57. outs = list(map(aesara_code_, exprs))
  58. ins = list(aesara.graph.basic.graph_inputs(outs))
  59. ins, outs = aesara.graph.basic.clone(ins, outs)
  60. return aesara.graph.fg.FunctionGraph(ins, outs)
  61. def aesara_simplify(fgraph):
  62. """ Simplify a Aesara Computation.
  63. Parameters
  64. ==========
  65. fgraph : aesara.graph.fg.FunctionGraph
  66. Returns
  67. =======
  68. aesara.graph.fg.FunctionGraph
  69. """
  70. mode = aesara.compile.get_default_mode().excluding("fusion")
  71. fgraph = fgraph.clone()
  72. mode.optimizer.optimize(fgraph)
  73. return fgraph
  74. def theq(a, b):
  75. """ Test two Aesara objects for equality.
  76. Also accepts numeric types and lists/tuples of supported types.
  77. Note - debugprint() has a bug where it will accept numeric types but does
  78. not respect the "file" argument and in this case and instead prints the number
  79. to stdout and returns an empty string. This can lead to tests passing where
  80. they should fail because any two numbers will always compare as equal. To
  81. prevent this we treat numbers as a separate case.
  82. """
  83. numeric_types = (int, float, np.number)
  84. a_is_num = isinstance(a, numeric_types)
  85. b_is_num = isinstance(b, numeric_types)
  86. # Compare numeric types using regular equality
  87. if a_is_num or b_is_num:
  88. if not (a_is_num and b_is_num):
  89. return False
  90. return a == b
  91. # Compare sequences element-wise
  92. a_is_seq = isinstance(a, (tuple, list))
  93. b_is_seq = isinstance(b, (tuple, list))
  94. if a_is_seq or b_is_seq:
  95. if not (a_is_seq and b_is_seq) or type(a) != type(b):
  96. return False
  97. return list(map(theq, a)) == list(map(theq, b))
  98. # Otherwise, assume debugprint() can handle it
  99. astr = aesara.printing.debugprint(a, file='str')
  100. bstr = aesara.printing.debugprint(b, file='str')
  101. # Check for bug mentioned above
  102. for argname, argval, argstr in [('a', a, astr), ('b', b, bstr)]:
  103. if argstr == '':
  104. raise TypeError(
  105. 'aesara.printing.debugprint(%s) returned empty string '
  106. '(%s is instance of %r)'
  107. % (argname, argname, type(argval))
  108. )
  109. return astr == bstr
  110. def test_example_symbols():
  111. """
  112. Check that the example symbols in this module print to their Aesara
  113. equivalents, as many of the other tests depend on this.
  114. """
  115. assert theq(xt, aesara_code_(x))
  116. assert theq(yt, aesara_code_(y))
  117. assert theq(zt, aesara_code_(z))
  118. assert theq(Xt, aesara_code_(X))
  119. assert theq(Yt, aesara_code_(Y))
  120. assert theq(Zt, aesara_code_(Z))
  121. def test_Symbol():
  122. """ Test printing a Symbol to a aesara variable. """
  123. xx = aesara_code_(x)
  124. assert isinstance(xx, Variable)
  125. assert xx.broadcastable == ()
  126. assert xx.name == x.name
  127. xx2 = aesara_code_(x, broadcastables={x: (False,)})
  128. assert xx2.broadcastable == (False,)
  129. assert xx2.name == x.name
  130. def test_MatrixSymbol():
  131. """ Test printing a MatrixSymbol to a aesara variable. """
  132. XX = aesara_code_(X)
  133. assert isinstance(XX, TensorVariable)
  134. assert XX.broadcastable == (False, False)
  135. @SKIP # TODO - this is currently not checked but should be implemented
  136. def test_MatrixSymbol_wrong_dims():
  137. """ Test MatrixSymbol with invalid broadcastable. """
  138. bcs = [(), (False,), (True,), (True, False), (False, True,), (True, True)]
  139. for bc in bcs:
  140. with raises(ValueError):
  141. aesara_code_(X, broadcastables={X: bc})
  142. def test_AppliedUndef():
  143. """ Test printing AppliedUndef instance, which works similarly to Symbol. """
  144. ftt = aesara_code_(f_t)
  145. assert isinstance(ftt, TensorVariable)
  146. assert ftt.broadcastable == ()
  147. assert ftt.name == 'f_t'
  148. def test_add():
  149. expr = x + y
  150. comp = aesara_code_(expr)
  151. assert comp.owner.op == aesara.tensor.add
  152. def test_trig():
  153. assert theq(aesara_code_(sy.sin(x)), aet.sin(xt))
  154. assert theq(aesara_code_(sy.tan(x)), aet.tan(xt))
  155. def test_many():
  156. """ Test printing a complex expression with multiple symbols. """
  157. expr = sy.exp(x**2 + sy.cos(y)) * sy.log(2*z)
  158. comp = aesara_code_(expr)
  159. expected = aet.exp(xt**2 + aet.cos(yt)) * aet.log(2*zt)
  160. assert theq(comp, expected)
  161. def test_dtype():
  162. """ Test specifying specific data types through the dtype argument. """
  163. for dtype in ['float32', 'float64', 'int8', 'int16', 'int32', 'int64']:
  164. assert aesara_code_(x, dtypes={x: dtype}).type.dtype == dtype
  165. # "floatX" type
  166. assert aesara_code_(x, dtypes={x: 'floatX'}).type.dtype in ('float32', 'float64')
  167. # Type promotion
  168. assert aesara_code_(x + 1, dtypes={x: 'float32'}).type.dtype == 'float32'
  169. assert aesara_code_(x + y, dtypes={x: 'float64', y: 'float32'}).type.dtype == 'float64'
  170. def test_broadcastables():
  171. """ Test the "broadcastables" argument when printing symbol-like objects. """
  172. # No restrictions on shape
  173. for s in [x, f_t]:
  174. for bc in [(), (False,), (True,), (False, False), (True, False)]:
  175. assert aesara_code_(s, broadcastables={s: bc}).broadcastable == bc
  176. # TODO - matrix broadcasting?
  177. def test_broadcasting():
  178. """ Test "broadcastable" attribute after applying element-wise binary op. """
  179. expr = x + y
  180. cases = [
  181. [(), (), ()],
  182. [(False,), (False,), (False,)],
  183. [(True,), (False,), (False,)],
  184. [(False, True), (False, False), (False, False)],
  185. [(True, False), (False, False), (False, False)],
  186. ]
  187. for bc1, bc2, bc3 in cases:
  188. comp = aesara_code_(expr, broadcastables={x: bc1, y: bc2})
  189. assert comp.broadcastable == bc3
  190. def test_MatMul():
  191. expr = X*Y*Z
  192. expr_t = aesara_code_(expr)
  193. assert isinstance(expr_t.owner.op, Dot)
  194. assert theq(expr_t, Xt.dot(Yt).dot(Zt))
  195. def test_Transpose():
  196. assert isinstance(aesara_code_(X.T).owner.op, DimShuffle)
  197. def test_MatAdd():
  198. expr = X+Y+Z
  199. assert isinstance(aesara_code_(expr).owner.op, Elemwise)
  200. def test_Rationals():
  201. assert theq(aesara_code_(sy.Integer(2) / 3), aet.true_div(2, 3))
  202. assert theq(aesara_code_(S.Half), aet.true_div(1, 2))
  203. def test_Integers():
  204. assert aesara_code_(sy.Integer(3)) == 3
  205. def test_factorial():
  206. n = sy.Symbol('n')
  207. assert aesara_code_(sy.factorial(n))
  208. def test_Derivative():
  209. simp = lambda expr: aesara_simplify(fgraph_of(expr))
  210. assert theq(simp(aesara_code_(sy.Derivative(sy.sin(x), x, evaluate=False))),
  211. simp(aesara.grad(aet.sin(xt), xt)))
  212. def test_aesara_function_simple():
  213. """ Test aesara_function() with single output. """
  214. f = aesara_function_([x, y], [x+y])
  215. assert f(2, 3) == 5
  216. def test_aesara_function_multi():
  217. """ Test aesara_function() with multiple outputs. """
  218. f = aesara_function_([x, y], [x+y, x-y])
  219. o1, o2 = f(2, 3)
  220. assert o1 == 5
  221. assert o2 == -1
  222. def test_aesara_function_numpy():
  223. """ Test aesara_function() vs Numpy implementation. """
  224. f = aesara_function_([x, y], [x+y], dim=1,
  225. dtypes={x: 'float64', y: 'float64'})
  226. assert np.linalg.norm(f([1, 2], [3, 4]) - np.asarray([4, 6])) < 1e-9
  227. f = aesara_function_([x, y], [x+y], dtypes={x: 'float64', y: 'float64'},
  228. dim=1)
  229. xx = np.arange(3).astype('float64')
  230. yy = 2*np.arange(3).astype('float64')
  231. assert np.linalg.norm(f(xx, yy) - 3*np.arange(3)) < 1e-9
  232. def test_aesara_function_matrix():
  233. m = sy.Matrix([[x, y], [z, x + y + z]])
  234. expected = np.array([[1.0, 2.0], [3.0, 1.0 + 2.0 + 3.0]])
  235. f = aesara_function_([x, y, z], [m])
  236. np.testing.assert_allclose(f(1.0, 2.0, 3.0), expected)
  237. f = aesara_function_([x, y, z], [m], scalar=True)
  238. np.testing.assert_allclose(f(1.0, 2.0, 3.0), expected)
  239. f = aesara_function_([x, y, z], [m, m])
  240. assert isinstance(f(1.0, 2.0, 3.0), type([]))
  241. np.testing.assert_allclose(f(1.0, 2.0, 3.0)[0], expected)
  242. np.testing.assert_allclose(f(1.0, 2.0, 3.0)[1], expected)
  243. def test_dim_handling():
  244. assert dim_handling([x], dim=2) == {x: (False, False)}
  245. assert dim_handling([x, y], dims={x: 1, y: 2}) == {x: (False, True),
  246. y: (False, False)}
  247. assert dim_handling([x], broadcastables={x: (False,)}) == {x: (False,)}
  248. def test_aesara_function_kwargs():
  249. """
  250. Test passing additional kwargs from aesara_function() to aesara.function().
  251. """
  252. import numpy as np
  253. f = aesara_function_([x, y, z], [x+y], dim=1, on_unused_input='ignore',
  254. dtypes={x: 'float64', y: 'float64', z: 'float64'})
  255. assert np.linalg.norm(f([1, 2], [3, 4], [0, 0]) - np.asarray([4, 6])) < 1e-9
  256. f = aesara_function_([x, y, z], [x+y],
  257. dtypes={x: 'float64', y: 'float64', z: 'float64'},
  258. dim=1, on_unused_input='ignore')
  259. xx = np.arange(3).astype('float64')
  260. yy = 2*np.arange(3).astype('float64')
  261. zz = 2*np.arange(3).astype('float64')
  262. assert np.linalg.norm(f(xx, yy, zz) - 3*np.arange(3)) < 1e-9
  263. def test_aesara_function_scalar():
  264. """ Test the "scalar" argument to aesara_function(). """
  265. from aesara.compile.function.types import Function
  266. args = [
  267. ([x, y], [x + y], None, [0]), # Single 0d output
  268. ([X, Y], [X + Y], None, [2]), # Single 2d output
  269. ([x, y], [x + y], {x: 0, y: 1}, [1]), # Single 1d output
  270. ([x, y], [x + y, x - y], None, [0, 0]), # Two 0d outputs
  271. ([x, y, X, Y], [x + y, X + Y], None, [0, 2]), # One 0d output, one 2d
  272. ]
  273. # Create and test functions with and without the scalar setting
  274. for inputs, outputs, in_dims, out_dims in args:
  275. for scalar in [False, True]:
  276. f = aesara_function_(inputs, outputs, dims=in_dims, scalar=scalar)
  277. # Check the aesara_function attribute is set whether wrapped or not
  278. assert isinstance(f.aesara_function, Function)
  279. # Feed in inputs of the appropriate size and get outputs
  280. in_values = [
  281. np.ones([1 if bc else 5 for bc in i.type.broadcastable])
  282. for i in f.aesara_function.input_storage
  283. ]
  284. out_values = f(*in_values)
  285. if not isinstance(out_values, list):
  286. out_values = [out_values]
  287. # Check output types and shapes
  288. assert len(out_dims) == len(out_values)
  289. for d, value in zip(out_dims, out_values):
  290. if scalar and d == 0:
  291. # Should have been converted to a scalar value
  292. assert isinstance(value, np.number)
  293. else:
  294. # Otherwise should be an array
  295. assert isinstance(value, np.ndarray)
  296. assert value.ndim == d
  297. def test_aesara_function_bad_kwarg():
  298. """
  299. Passing an unknown keyword argument to aesara_function() should raise an
  300. exception.
  301. """
  302. raises(Exception, lambda : aesara_function_([x], [x+1], foobar=3))
  303. def test_slice():
  304. assert aesara_code_(slice(1, 2, 3)) == slice(1, 2, 3)
  305. def theq_slice(s1, s2):
  306. for attr in ['start', 'stop', 'step']:
  307. a1 = getattr(s1, attr)
  308. a2 = getattr(s2, attr)
  309. if a1 is None or a2 is None:
  310. if not (a1 is None or a2 is None):
  311. return False
  312. elif not theq(a1, a2):
  313. return False
  314. return True
  315. dtypes = {x: 'int32', y: 'int32'}
  316. assert theq_slice(aesara_code_(slice(x, y), dtypes=dtypes), slice(xt, yt))
  317. assert theq_slice(aesara_code_(slice(1, x, 3), dtypes=dtypes), slice(1, xt, 3))
  318. def test_MatrixSlice():
  319. from aesara.graph.basic import Constant
  320. cache = {}
  321. n = sy.Symbol('n', integer=True)
  322. X = sy.MatrixSymbol('X', n, n)
  323. Y = X[1:2:3, 4:5:6]
  324. Yt = aesara_code_(Y, cache=cache)
  325. s = Scalar('int64')
  326. assert tuple(Yt.owner.op.idx_list) == (slice(s, s, s), slice(s, s, s))
  327. assert Yt.owner.inputs[0] == aesara_code_(X, cache=cache)
  328. # == doesn't work in Aesara like it does in SymPy. You have to use
  329. # equals.
  330. assert all(Yt.owner.inputs[i].equals(Constant(s, i)) for i in range(1, 7))
  331. k = sy.Symbol('k')
  332. aesara_code_(k, dtypes={k: 'int32'})
  333. start, stop, step = 4, k, 2
  334. Y = X[start:stop:step]
  335. Yt = aesara_code_(Y, dtypes={n: 'int32', k: 'int32'})
  336. # assert Yt.owner.op.idx_list[0].stop == kt
  337. def test_BlockMatrix():
  338. n = sy.Symbol('n', integer=True)
  339. A, B, C, D = [sy.MatrixSymbol(name, n, n) for name in 'ABCD']
  340. At, Bt, Ct, Dt = map(aesara_code_, (A, B, C, D))
  341. Block = sy.BlockMatrix([[A, B], [C, D]])
  342. Blockt = aesara_code_(Block)
  343. solutions = [aet.join(0, aet.join(1, At, Bt), aet.join(1, Ct, Dt)),
  344. aet.join(1, aet.join(0, At, Ct), aet.join(0, Bt, Dt))]
  345. assert any(theq(Blockt, solution) for solution in solutions)
  346. @SKIP
  347. def test_BlockMatrix_Inverse_execution():
  348. k, n = 2, 4
  349. dtype = 'float32'
  350. A = sy.MatrixSymbol('A', n, k)
  351. B = sy.MatrixSymbol('B', n, n)
  352. inputs = A, B
  353. output = B.I*A
  354. cutsizes = {A: [(n//2, n//2), (k//2, k//2)],
  355. B: [(n//2, n//2), (n//2, n//2)]}
  356. cutinputs = [sy.blockcut(i, *cutsizes[i]) for i in inputs]
  357. cutoutput = output.subs(dict(zip(inputs, cutinputs)))
  358. dtypes = dict(zip(inputs, [dtype]*len(inputs)))
  359. f = aesara_function_(inputs, [output], dtypes=dtypes, cache={})
  360. fblocked = aesara_function_(inputs, [sy.block_collapse(cutoutput)],
  361. dtypes=dtypes, cache={})
  362. ninputs = [np.random.rand(*x.shape).astype(dtype) for x in inputs]
  363. ninputs = [np.arange(n*k).reshape(A.shape).astype(dtype),
  364. np.eye(n).astype(dtype)]
  365. ninputs[1] += np.ones(B.shape)*1e-5
  366. assert np.allclose(f(*ninputs), fblocked(*ninputs), rtol=1e-5)
  367. def test_DenseMatrix():
  368. from aesara.tensor.basic import Join
  369. t = sy.Symbol('theta')
  370. for MatrixType in [sy.Matrix, sy.ImmutableMatrix]:
  371. X = MatrixType([[sy.cos(t), -sy.sin(t)], [sy.sin(t), sy.cos(t)]])
  372. tX = aesara_code_(X)
  373. assert isinstance(tX, TensorVariable)
  374. assert isinstance(tX.owner.op, Join)
  375. def test_cache_basic():
  376. """ Test single symbol-like objects are cached when printed by themselves. """
  377. # Pairs of objects which should be considered equivalent with respect to caching
  378. pairs = [
  379. (x, sy.Symbol('x')),
  380. (X, sy.MatrixSymbol('X', *X.shape)),
  381. (f_t, sy.Function('f')(sy.Symbol('t'))),
  382. ]
  383. for s1, s2 in pairs:
  384. cache = {}
  385. st = aesara_code_(s1, cache=cache)
  386. # Test hit with same instance
  387. assert aesara_code_(s1, cache=cache) is st
  388. # Test miss with same instance but new cache
  389. assert aesara_code_(s1, cache={}) is not st
  390. # Test hit with different but equivalent instance
  391. assert aesara_code_(s2, cache=cache) is st
  392. def test_global_cache():
  393. """ Test use of the global cache. """
  394. from sympy.printing.aesaracode import global_cache
  395. backup = dict(global_cache)
  396. try:
  397. # Temporarily empty global cache
  398. global_cache.clear()
  399. for s in [x, X, f_t]:
  400. st = aesara_code(s)
  401. assert aesara_code(s) is st
  402. finally:
  403. # Restore global cache
  404. global_cache.update(backup)
  405. def test_cache_types_distinct():
  406. """
  407. Test that symbol-like objects of different types (Symbol, MatrixSymbol,
  408. AppliedUndef) are distinguished by the cache even if they have the same
  409. name.
  410. """
  411. symbols = [sy.Symbol('f_t'), sy.MatrixSymbol('f_t', 4, 4), f_t]
  412. cache = {} # Single shared cache
  413. printed = {}
  414. for s in symbols:
  415. st = aesara_code_(s, cache=cache)
  416. assert st not in printed.values()
  417. printed[s] = st
  418. # Check all printed objects are distinct
  419. assert len(set(map(id, printed.values()))) == len(symbols)
  420. # Check retrieving
  421. for s, st in printed.items():
  422. assert aesara_code(s, cache=cache) is st
  423. def test_symbols_are_created_once():
  424. """
  425. Test that a symbol is cached and reused when it appears in an expression
  426. more than once.
  427. """
  428. expr = sy.Add(x, x, evaluate=False)
  429. comp = aesara_code_(expr)
  430. assert theq(comp, xt + xt)
  431. assert not theq(comp, xt + aesara_code_(x))
  432. def test_cache_complex():
  433. """
  434. Test caching on a complicated expression with multiple symbols appearing
  435. multiple times.
  436. """
  437. expr = x ** 2 + (y - sy.exp(x)) * sy.sin(z - x * y)
  438. symbol_names = {s.name for s in expr.free_symbols}
  439. expr_t = aesara_code_(expr)
  440. # Iterate through variables in the Aesara computational graph that the
  441. # printed expression depends on
  442. seen = set()
  443. for v in aesara.graph.basic.ancestors([expr_t]):
  444. # Owner-less, non-constant variables should be our symbols
  445. if v.owner is None and not isinstance(v, aesara.graph.basic.Constant):
  446. # Check it corresponds to a symbol and appears only once
  447. assert v.name in symbol_names
  448. assert v.name not in seen
  449. seen.add(v.name)
  450. # Check all were present
  451. assert seen == symbol_names
  452. def test_Piecewise():
  453. # A piecewise linear
  454. expr = sy.Piecewise((0, x<0), (x, x<2), (1, True)) # ___/III
  455. result = aesara_code_(expr)
  456. assert result.owner.op == aet.switch
  457. expected = aet.switch(xt<0, 0, aet.switch(xt<2, xt, 1))
  458. assert theq(result, expected)
  459. expr = sy.Piecewise((x, x < 0))
  460. result = aesara_code_(expr)
  461. expected = aet.switch(xt < 0, xt, np.nan)
  462. assert theq(result, expected)
  463. expr = sy.Piecewise((0, sy.And(x>0, x<2)), \
  464. (x, sy.Or(x>2, x<0)))
  465. result = aesara_code_(expr)
  466. expected = aet.switch(aet.and_(xt>0,xt<2), 0, \
  467. aet.switch(aet.or_(xt>2, xt<0), xt, np.nan))
  468. assert theq(result, expected)
  469. def test_Relationals():
  470. assert theq(aesara_code_(sy.Eq(x, y)), aet.eq(xt, yt))
  471. # assert theq(aesara_code_(sy.Ne(x, y)), aet.neq(xt, yt)) # TODO - implement
  472. assert theq(aesara_code_(x > y), xt > yt)
  473. assert theq(aesara_code_(x < y), xt < yt)
  474. assert theq(aesara_code_(x >= y), xt >= yt)
  475. assert theq(aesara_code_(x <= y), xt <= yt)
  476. def test_complexfunctions():
  477. xt, yt = aesara_code(x, dtypes={x:'complex128'}), aesara_code(y, dtypes={y: 'complex128'})
  478. from sympy.functions.elementary.complexes import conjugate
  479. from aesara.tensor import as_tensor_variable as atv
  480. from aesara.tensor import complex as cplx
  481. assert theq(aesara_code(y*conjugate(x)), yt*(xt.conj()))
  482. assert theq(aesara_code((1+2j)*x), xt*(atv(1.0)+atv(2.0)*cplx(0,1)))
  483. def test_constantfunctions():
  484. tf = aesara_function([],[1+1j])
  485. assert(tf()==1+1j)