diff --git a/src/pyoframe/constants.py b/src/pyoframe/constants.py index cbff7e1..a0da37c 100644 --- a/src/pyoframe/constants.py +++ b/src/pyoframe/constants.py @@ -132,7 +132,10 @@ def process(cls, status: str) -> "SolverStatus": def from_termination_condition( cls, termination_condition: "TerminationCondition" ) -> "SolverStatus": - for status, termination_conditions in STATUS_TO_TERMINATION_CONDITION_MAP.items(): + for ( + status, + termination_conditions, + ) in STATUS_TO_TERMINATION_CONDITION_MAP.items(): if termination_condition in termination_conditions: return status return cls("unknown") diff --git a/src/pyoframe/core.py b/src/pyoframe/core.py index edd3ca7..fe8031b 100644 --- a/src/pyoframe/core.py +++ b/src/pyoframe/core.py @@ -709,7 +709,9 @@ def value(self) -> pl.DataFrame: >>> m.objective.value 63.0 """ - assert self._model is not None, "Expression must be added to the model to use .value" + assert ( + self._model is not None + ), "Expression must be added to the model to use .value" if self._model.result is None or self._model.result.solution is None: raise ValueError( "Can't obtain value of expression since the model has not been solved." @@ -925,7 +927,9 @@ def slack(self): The first call to this property will load the slack values from the solver (lazy loading). """ if SLACK_COL not in self.data.columns: - assert self._model is not None, "Constraint must be added to a model to get the slack." + assert ( + self._model is not None + ), "Constraint must be added to a model to get the slack." if self._model.solver is None: raise ValueError("The model has not been solved yet.") self._model.solver.load_slack() @@ -1224,7 +1228,9 @@ def RC(self): The first call to this property will load the reduced costs from the solver (lazy loading). """ if RC_COL not in self.data.columns: - assert self._model is not None, "Variable must be added to a model to get the reduced cost." + assert ( + self._model is not None + ), "Variable must be added to a model to get the reduced cost." if self._model.solver is None: raise ValueError("The model has not been solved yet.") self._model.solver.load_rc() diff --git a/src/pyoframe/model.py b/src/pyoframe/model.py index cd8e72b..373cc46 100644 --- a/src/pyoframe/model.py +++ b/src/pyoframe/model.py @@ -37,7 +37,7 @@ class Model(AttrContainerMixin): "result", "attr", "sense", - "objective" + "objective", ] def __init__(self, min_or_max: Union[ObjSense, ObjSenseValue], name=None, **kwargs): @@ -75,7 +75,7 @@ def constraints(self): @property def objective(self): return self._objective - + @objective.setter def objective(self, value): value = Objective(value)