Skip to content

Commit c623124

Browse files
committed
Handle incompatible issues with numba and c unboxing of boolean scalars
1 parent eee34a3 commit c623124

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pytensor/tensor/signal/conv.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,11 @@ def __init__(self, method: Literal["direct", "fft", "auto"] = "auto"):
255255
def perform(self, node, inputs, outputs):
256256
in1, in2, full_mode = inputs
257257

258-
# TODO: Why is .item() needed?
259-
mode: Literal["full", "valid", "same"] = "full" if full_mode.item() else "valid"
258+
if isinstance(full_mode, np.bool):
259+
# Patch for wrong unboxing of bool scalars in C backend
260+
# Conditional, because numba will produce a bool, not np.bool_
261+
full_mode = full_mode.item()
262+
mode = "full" if full_mode else "valid"
260263
outputs[0][0] = scipy_convolve(in1, in2, mode=mode, method=self.method)
261264

262265

0 commit comments

Comments
 (0)