提交 f0244adf authored 作者: ricardoV94's avatar ricardoV94 提交者: Luciano Paz

Raise NotImplementedError for boolean scalar indexing

This is a special-edge case that behaves differently than other boolean indexing. It adds a new dimension (either empty or with one entry). The logic in `make_node` and `infer_shape` don't handle this.
上级 03e5f772
......@@ -2627,6 +2627,11 @@ def as_index_variable(idx):
idx = as_tensor_variable(idx)
if idx.type.dtype not in discrete_dtypes:
raise TypeError("index must be integers or a boolean mask")
if idx.type.dtype == "bool" and idx.type.ndim == 0:
raise NotImplementedError(
"Boolean scalar indexing not implemented. "
"Open an issue in https://github.com/pymc-devs/pytensor/issues if you need this behavior."
)
return idx
......
......@@ -2228,6 +2228,11 @@ class TestAdvancedSubtensor:
mode=self.mode,
)
def test_boolean_scalar_raises(self):
x = vector("x")
with pytest.raises(NotImplementedError):
x[np.array(True)]
class TestInferShape(utt.InferShapeTester):
@staticmethod
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论