Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytensor/tensor/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def analyze(x):
and is_step_constant
and is_length_constant
):
assert isinstance(length, int)
assert isinstance(length, int | np.integer)
_start, _stop, _step = slice(start, stop, step).indices(length)
if _start <= _stop and _step >= 1:
return slice(_start, _stop, _step), 1
Expand Down
7 changes: 5 additions & 2 deletions tests/tensor/test_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,11 @@ def test_symbolic_tensor(self):
assert isinstance(res[0].owner.op, ptb.ScalarFromTensor)
assert res[1] == 1

def test_all_integer(self):
res = get_canonical_form_slice(slice(1, 5, 2), 7)
@pytest.mark.parametrize("int_fn", [int, np.int64, as_tensor, as_scalar])
def test_all_integer(self, int_fn):
res = get_canonical_form_slice(
slice(int_fn(1), int_fn(5), int_fn(2)), int_fn(7)
)
assert isinstance(res[0], slice)
assert res[1] == 1

Expand Down