From b734e079f087a1909aaaaef29cf04334c85e0661 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 5 Dec 2018 10:57:33 +0100 Subject: [PATCH] refactor: add deprecation warnings --- cobra/core/reaction.py | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/cobra/core/reaction.py b/cobra/core/reaction.py index aec4cf09d..9fc058af4 100644 --- a/cobra/core/reaction.py +++ b/cobra/core/reaction.py @@ -184,20 +184,6 @@ def __deepcopy__(self, memo): cop = deepcopy(super(Reaction, self), memo) return cop - @property - def lower_bound(self): - """Get or set the lower bound - - Setting the lower bound (float) will also adjust the associated optlang - variables associated with the reaction. Infeasible combinations, - such as a lower bound higher than the current upper bound will - update the other bound. - - When using a `HistoryManager` context, this attribute can be set - temporarily, reversed when the exiting the context. - """ - return self._lower_bound - @staticmethod def _check_bounds(lb, ub): if lb > ub: @@ -231,10 +217,30 @@ def update_variable_bounds(self): ub=None if isinf(self._lower_bound) else -self._lower_bound ) + @property + def lower_bound(self): + """Get or set the lower bound + + Setting the lower bound (float) will also adjust the associated optlang + variables associated with the reaction. Infeasible combinations, + such as a lower bound higher than the current upper bound will + update the other bound. + + When using a `HistoryManager` context, this attribute can be set + temporarily, reversed when the exiting the context. + """ + return self._lower_bound + @lower_bound.setter @resettable def lower_bound(self, value): if self._upper_bound < value: + warn("You are constraining the reaction '{}' to a fixed flux " + "value of {}. Did you intend to do this? We are planning to " + "remove this behavior in a future release. Please let us " + "know your opinion at " + "https://github.com/opencobra/cobrapy/issues/793." + "".format(self.id, value), DeprecationWarning) self.upper_bound = value # Validate bounds before setting them. self._check_bounds(value, self._upper_bound) @@ -259,6 +265,12 @@ def upper_bound(self): @resettable def upper_bound(self, value): if self._lower_bound > value: + warn("You are constraining the reaction '{}' to a fixed flux " + "value of {}. Did you intend to do this? We are planning to " + "remove this behavior in a future release. Please let us " + "know your opinion at " + "https://github.com/opencobra/cobrapy/issues/793." + "".format(self.id, value), DeprecationWarning) self.lower_bound = value # Validate bounds before setting them. self._check_bounds(self._lower_bound, value)