File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ class FixedConstraintWithValue(om.FixedConstraint):
4040 value : float | None = None
4141 """Value to enforce on the parameter."""
4242
43+ def __post_init__ (self ) -> None :
44+ """Validate that `loc` and `value` are not None."""
45+ if self .loc is None :
46+ msg = "loc must not be None"
47+ raise TypeError (msg )
48+ if self .value is None :
49+ msg = "value must not be None"
50+ raise TypeError (msg )
51+
4352
4453def get_constraints (
4554 dimensions : Dimensions ,
@@ -490,10 +499,7 @@ def enforce_fixed_constraints(
490499 message = "indexing past lexsort depth may impact performance." ,
491500 )
492501 for constraint in constraints :
493- if (
494- isinstance (constraint , FixedConstraintWithValue )
495- and constraint .value is not None
496- ):
502+ if isinstance (constraint , FixedConstraintWithValue ):
497503 params .loc [constraint .loc , "value" ] = constraint .value
498504
499505 # Setting via loc may expand the index, so reduce to the original index
You can’t perform that action at this time.
0 commit comments