Skip to content

Commit

Permalink
add __getattr__ for _BaseDebugSolverWrapper (watertap-org/watertap#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
bknueven authored Sep 13, 2024
1 parent 3e2bfc4 commit 2a42ff6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/watertap_solvers/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ def __init__(self, **kwds):

self._value_cache = pyo.ComponentMap()

def __getattr__(self, attr):
# if not available here, ask the base_solver
try:
return getattr(pyo.SolverFactory(self._base_solver), attr)
except AttributeError:
raise

def restore_initial_values(self, blk):
for var in blk.component_data_objects(pyo.Var, descend_into=True):
var.set_value(self._value_cache[var], skip_validation=True)
Expand Down

0 comments on commit 2a42ff6

Please sign in to comment.