Skip to content

Commit 0cd959e

Browse files
More mypy
1 parent e2e2c84 commit 0cd959e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pytensor/tensor/optimize.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,11 @@ def __init__(
362362
method: str = "brent",
363363
optimizer_kwargs: dict | None = None,
364364
):
365-
if not x.ndim == 0:
365+
if not cast(TensorVariable, x).ndim == 0:
366366
raise ValueError(
367367
"The variable `x` must be a scalar (0-dimensional) tensor for minimize_scalar."
368368
)
369-
if not objective.ndim == 0:
369+
if not cast(TensorVariable, objective).ndim == 0:
370370
raise ValueError(
371371
"The objective function must be a scalar (0-dimensional) tensor for minimize_scalar."
372372
)
@@ -455,11 +455,11 @@ def __init__(
455455
hessp: bool = False,
456456
optimizer_kwargs: dict | None = None,
457457
):
458-
if not objective.ndim == 0:
458+
if not cast(TensorVariable, objective).ndim == 0:
459459
raise ValueError(
460460
"The objective function must be a scalar (0-dimensional) tensor for minimize."
461461
)
462-
if not isinstance(x, Variable) and x not in ancestors([objective]):
462+
if x not in ancestors([objective]):
463463
raise ValueError(
464464
"The variable `x` must be an input to the computational graph of the objective function."
465465
)
@@ -712,7 +712,7 @@ def __init__(
712712
jac: bool = True,
713713
optimizer_kwargs: dict | None = None,
714714
):
715-
if variables.ndim != equations.ndim:
715+
if cast(TensorVariable, variables).ndim != cast(TensorVariable, equations).ndim:
716716
raise ValueError(
717717
"The variable `variables` must have the same number of dimensions as the equations."
718718
)

0 commit comments

Comments
 (0)