diff --git a/pytato/utils.py b/pytato/utils.py index 1eba387ff28a955427c80ed4836885860aba9f1f..f5d784517fc1be6aee2725c9cb0ef9024cf13c26 100644 --- a/pytato/utils.py +++ b/pytato/utils.py @@ -521,6 +521,10 @@ def _index_into(ary: Array, indices: Tuple[ConvertibleToIndexExpr, ...]) -> Arra elif isinstance(idx, Array): if idx.dtype.kind not in ["i", "u"]: raise IndexError("only integer arrays are valid array indices") + if (_is_non_positive(ary.shape[i]) + and (not are_shape_components_equal(idx.size, 0))): + raise IndexError("Indirect indexing into a non-postive" + f" dimension (axis {i}) is illegal.") else: raise IndexError("only integers, slices, ellipsis and integer arrays" " are valid indices")