Skip to content

Commit c184189

Browse files
committed
update docstring
1 parent 13b0d9c commit c184189

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

linopy/model.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,21 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
102102
assert isinstance(self, Model), (
103103
f"First argument must be a Model instance, got {type(self)}"
104104
)
105-
model = self
106-
if not self.objective.has_constant:
105+
model: Model = self
106+
if not model.objective.has_constant:
107107
# Continue as normal if there is no constant term
108108
return func(*args, **kwargs)
109109

110110
# The objective contains a constant term
111111
# Modify the model objective to drop the constant term
112-
model = self
113-
constant = float(self.objective.expression.const.values)
114-
model.objective.expression = self.objective.expression.drop_constant()
112+
constant = float(model.objective.expression.const.values)
113+
model.objective.expression = model.objective.expression.drop_constant()
115114
args = (model, *args[1:]) # type: ignore
116115

117116
try:
118117
result = func(*args, **kwargs)
119118
except Exception as e:
120-
# Even if there is an exception, make sure the model returns to it's original state
119+
# Even if there is an exception, make sure the model returns to its original state
121120
model.objective.expression = model.objective.expression + constant
122121
raise e
123122

0 commit comments

Comments
 (0)