Skip to content

Commit

Permalink
refactor: add deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Midnighter committed Dec 5, 2018
1 parent d53ac06 commit b734e07
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions cobra/core/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit b734e07

Please sign in to comment.