Skip to content

Commit ff104c0

Browse files
Fix for NameError in test
I was getting a NameError from the list comprehensions saying that e.g. `pytensor_scalar` was not defined. I'm not sure why, but this is another (more verbose) way to do the same thing.
1 parent 65219d8 commit ff104c0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/tensor/test_math.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,11 +2457,22 @@ def pytensor_i_scalar(dtype):
24572457
def numpy_i_scalar(dtype):
24582458
return numpy_scalar(dtype)
24592459

2460+
pytensor_funcs = {
2461+
"scalar": pytensor_scalar,
2462+
"array": pytensor_array,
2463+
"i_scalar": pytensor_i_scalar,
2464+
}
2465+
numpy_funcs = {
2466+
"scalar": numpy_scalar,
2467+
"array": numpy_array,
2468+
"i_scalar": numpy_i_scalar,
2469+
}
2470+
24602471
with config.change_flags(cast_policy="numpy+floatX"):
24612472
# We will test all meaningful combinations of
24622473
# scalar and array operations.
2463-
pytensor_args = [eval(f"pytensor_{c}") for c in combo]
2464-
numpy_args = [eval(f"numpy_{c}") for c in combo]
2474+
pytensor_args = [pytensor_funcs[c] for c in combo]
2475+
numpy_args = [numpy_funcs[c] for c in combo]
24652476
pytensor_arg_1 = pytensor_args[0](a_type)
24662477
pytensor_arg_2 = pytensor_args[1](b_type)
24672478
pytensor_dtype = op(

0 commit comments

Comments
 (0)