diff --git a/pytensor/tensor/subtensor.py b/pytensor/tensor/subtensor.py index f3532c895a..87a62cad81 100644 --- a/pytensor/tensor/subtensor.py +++ b/pytensor/tensor/subtensor.py @@ -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 diff --git a/tests/tensor/test_subtensor.py b/tests/tensor/test_subtensor.py index aebd60de56..7b3f9af617 100644 --- a/tests/tensor/test_subtensor.py +++ b/tests/tensor/test_subtensor.py @@ -2228,6 +2228,11 @@ def fun(x, y): 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