|
9 | 9 | # This software is distributed under the 3-clause BSD License.
|
10 | 10 | # ___________________________________________________________________________
|
11 | 11 |
|
| 12 | +from pyomo.common.modeling import NOTSET |
12 | 13 | from pyomo.core.expr.numvalue import (
|
13 | 14 | ZeroConstant,
|
14 | 15 | as_numeric,
|
15 | 16 | is_potentially_variable,
|
16 | 17 | is_numeric_data,
|
17 | 18 | value,
|
18 | 19 | )
|
19 |
| -from pyomo.core.expr.expr_common import ExpressionType |
| 20 | +from pyomo.core.expr.expr_common import ExpressionType, _type_check_exception_arg |
20 | 21 | from pyomo.core.expr.relational_expr import (
|
21 | 22 | EqualityExpression,
|
22 | 23 | RangedExpression,
|
@@ -74,8 +75,9 @@ class IConstraint(ICategorizedObject):
|
74 | 75 | # Interface
|
75 | 76 | #
|
76 | 77 |
|
77 |
| - def __call__(self, exception=True): |
| 78 | + def __call__(self, exception=NOTSET): |
78 | 79 | """Compute the value of the body of this constraint."""
|
| 80 | + exception = _type_check_exception_arg(self, exception) |
79 | 81 | if exception and (self.body is None):
|
80 | 82 | raise ValueError("constraint body is None")
|
81 | 83 | elif self.body is None:
|
@@ -798,7 +800,8 @@ def terms(self, terms):
|
798 | 800 | # to avoid building the body expression
|
799 | 801 | #
|
800 | 802 |
|
801 |
| - def __call__(self, exception=True): |
| 803 | + def __call__(self, exception=NOTSET): |
| 804 | + exception = _type_check_exception_arg(self, exception) |
802 | 805 | try:
|
803 | 806 | return sum(
|
804 | 807 | value(c, exception=exception) * v(exception=exception)
|
|
0 commit comments