Skip to content

Commit 737b8cb

Browse files
CopilotricardoV94
authored andcommitted
Final fix: use as_index_variable consistently with original implementation
Co-authored-by: ricardoV94 <28983449+ricardoV94@users.noreply.github.com>
1 parent c18b322 commit 737b8cb

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

pytensor/tensor/subtensor.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,15 +3181,8 @@ def advanced_subtensor(x, *args):
31813181
This function converts the arguments to work with the new AdvancedSubtensor
31823182
interface that separates slice structure from variable inputs.
31833183
"""
3184-
# Convert raw args to proper form first
3185-
processed_args = []
3186-
for arg in args:
3187-
if arg is None:
3188-
processed_args.append(NoneConst.clone())
3189-
elif isinstance(arg, slice):
3190-
processed_args.append(make_slice(arg))
3191-
else:
3192-
processed_args.append(as_tensor_variable(arg))
3184+
# Convert args using as_index_variable (like original AdvancedSubtensor did)
3185+
processed_args = tuple(map(as_index_variable, args))
31933186

31943187
# Now create idx_list and extract inputs
31953188
idx_list = []
@@ -3234,15 +3227,8 @@ def advanced_subtensor(x, *args):
32343227

32353228
def advanced_inc_subtensor(x, y, *args, **kwargs):
32363229
"""Create an AdvancedIncSubtensor operation for incrementing."""
3237-
# Convert raw args to proper form first
3238-
processed_args = []
3239-
for arg in args:
3240-
if arg is None:
3241-
processed_args.append(NoneConst.clone())
3242-
elif isinstance(arg, slice):
3243-
processed_args.append(make_slice(arg))
3244-
else:
3245-
processed_args.append(as_tensor_variable(arg))
3230+
# Convert args using as_index_variable (like original AdvancedIncSubtensor would)
3231+
processed_args = tuple(map(as_index_variable, args))
32463232

32473233
# Now create idx_list and extract inputs
32483234
idx_list = []

0 commit comments

Comments
 (0)