Skip to content

Commit 999a62c

Browse files
brendan-m-murphyricardoV94
authored andcommitted
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 f359c0c commit 999a62c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/tensor/test_math.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -2492,11 +2492,22 @@ def pytensor_i_scalar(dtype):
24922492
def numpy_i_scalar(dtype):
24932493
return numpy_scalar(dtype)
24942494

2495+
pytensor_funcs = {
2496+
"scalar": pytensor_scalar,
2497+
"array": pytensor_array,
2498+
"i_scalar": pytensor_i_scalar,
2499+
}
2500+
numpy_funcs = {
2501+
"scalar": numpy_scalar,
2502+
"array": numpy_array,
2503+
"i_scalar": numpy_i_scalar,
2504+
}
2505+
24952506
with config.change_flags(cast_policy="numpy+floatX"):
24962507
# We will test all meaningful combinations of
24972508
# scalar and array operations.
2498-
pytensor_args = [eval(f"pytensor_{c}") for c in combo]
2499-
numpy_args = [eval(f"numpy_{c}") for c in combo]
2509+
pytensor_args = [pytensor_funcs[c] for c in combo]
2510+
numpy_args = [numpy_funcs[c] for c in combo]
25002511
pytensor_arg_1 = pytensor_args[0](a_type)
25012512
pytensor_arg_2 = pytensor_args[1](b_type)
25022513
pytensor_dtype = op(

0 commit comments

Comments
 (0)