Skip to content

Commit 9afcdd8

Browse files
committed
Fix wrong type assert
Introduced in f9dfe70
1 parent df769f6 commit 9afcdd8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pytensor/tensor/subtensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def analyze(x):
325325
and is_step_constant
326326
and is_length_constant
327327
):
328-
assert isinstance(length, int)
328+
assert isinstance(length, int | np.integer)
329329
_start, _stop, _step = slice(start, stop, step).indices(length)
330330
if _start <= _stop and _step >= 1:
331331
return slice(_start, _stop, _step), 1

tests/tensor/test_subtensor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ def test_all_integer(self):
159159
assert isinstance(res[0], slice)
160160
assert res[1] == 1
161161

162+
res = get_canonical_form_slice(
163+
slice(np.int64(1), np.int64(5), np.int64(2)), np.int64(7)
164+
)
165+
assert isinstance(res[0], slice)
166+
assert res[1] == 1
167+
162168
def test_all_symbolic(self):
163169
start = iscalar("b")
164170
stop = iscalar("e")

0 commit comments

Comments
 (0)