Skip to content

Commit 3588dc1

Browse files
committed
type checking exception arg for kernel constraint
1 parent defb293 commit 3588dc1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pyomo/core/kernel/constraint.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
# This software is distributed under the 3-clause BSD License.
1010
# ___________________________________________________________________________
1111

12+
from pyomo.common.modeling import NOTSET
1213
from pyomo.core.expr.numvalue import (
1314
ZeroConstant,
1415
as_numeric,
1516
is_potentially_variable,
1617
is_numeric_data,
1718
value,
1819
)
19-
from pyomo.core.expr.expr_common import ExpressionType
20+
from pyomo.core.expr.expr_common import ExpressionType, _type_check_exception_arg
2021
from pyomo.core.expr.relational_expr import (
2122
EqualityExpression,
2223
RangedExpression,
@@ -74,8 +75,9 @@ class IConstraint(ICategorizedObject):
7475
# Interface
7576
#
7677

77-
def __call__(self, exception=True):
78+
def __call__(self, exception=NOTSET):
7879
"""Compute the value of the body of this constraint."""
80+
exception = _type_check_exception_arg(self, exception)
7981
if exception and (self.body is None):
8082
raise ValueError("constraint body is None")
8183
elif self.body is None:
@@ -798,7 +800,8 @@ def terms(self, terms):
798800
# to avoid building the body expression
799801
#
800802

801-
def __call__(self, exception=True):
803+
def __call__(self, exception=NOTSET):
804+
exception = _type_check_exception_arg(self, exception)
802805
try:
803806
return sum(
804807
value(c, exception=exception) * v(exception=exception)

0 commit comments

Comments
 (0)