Skip to content

Commit e2e2c84

Browse files
Check inputs to RootOp
1 parent cb3d7e7 commit e2e2c84

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pytensor/tensor/optimize.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,15 @@ def __init__(
712712
jac: bool = True,
713713
optimizer_kwargs: dict | None = None,
714714
):
715+
if variables.ndim != equations.ndim:
716+
raise ValueError(
717+
"The variable `variables` must have the same number of dimensions as the equations."
718+
)
719+
if variables not in ancestors([equations]):
720+
raise ValueError(
721+
"The variable `variables` must be an input to the computational graph of the equations."
722+
)
723+
715724
self.fgraph = FunctionGraph([variables, *args], [equations])
716725

717726
if jac:

0 commit comments

Comments
 (0)