Skip to content

Commit 7bb18f3

Browse files
committed
Fix numpy integer check in TensorType
Bug introduced in 6834740
1 parent 6834740 commit 7bb18f3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: pytensor/tensor/type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __init__(
109109
def parse_bcast_and_shape(s):
110110
if isinstance(s, (bool, np.bool_)):
111111
return 1 if s else None
112-
elif isinstance(s, (int, np.int_)):
112+
elif isinstance(s, (int, np.integer)):
113113
return int(s)
114114
elif s is None:
115115
return s

Diff for: tests/tensor/test_type.py

+6
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ def test_shape_type_conversion():
274274
assert t1.broadcastable == (False,)
275275
assert isinstance(t1.broadcastable[0], bool)
276276

277+
t1 = TensorType("float64", shape=np.array([3], dtype=np.int32))
278+
assert t1.shape == (3,)
279+
assert isinstance(t1.shape[0], int)
280+
assert t1.broadcastable == (False,)
281+
assert isinstance(t1.broadcastable[0], bool)
282+
277283
t2 = TensorType("float64", broadcastable=np.array([True, False], dtype="bool"))
278284
assert t2.shape == (1, None)
279285
assert isinstance(t2.shape[0], int)

0 commit comments

Comments
 (0)