Skip to content
Prev Previous commit
Next Next commit
added standard style of parameter handling for iosystem.__call__, add…
…ed _current_params to iosys class
  • Loading branch information
sawyerbfuller authored and bnavigator committed Nov 8, 2022
commit 826916d35d2061bd4c6ee8eb6ddfe107342a215b
9 changes: 3 additions & 6 deletions control/iosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def __init__(self, params={}, **kwargs):

# default parameters
self.params = params.copy()
self._current_params = self.params.copy()

def __mul__(sys2, sys1):
"""Multiply two input/output systems (series interconnection)"""
Expand Down Expand Up @@ -804,7 +805,7 @@ def __str__(self):
f"Output: {self.outfcn}"

# Return the value of a static nonlinear system
def __call__(sys, u, params=None, squeeze=None):
def __call__(sys, u, params={}, squeeze=None):
"""Evaluate a (static) nonlinearity at a given input value

If a nonlinear I/O system has no internal state, then evaluating the
Expand All @@ -830,12 +831,8 @@ def __call__(sys, u, params=None, squeeze=None):
"function evaluation is only supported for static "
"input/output systems")

# If we received any parameters, update them before calling _out()
if params is not None:
sys._update_params(params)

# Evaluate the function on the argument
out = sys._out(0, np.array((0,)), np.asarray(u))
out = sys._out(0, np.array((0,)), np.asarray(u), params)
_, out = _process_time_response(
None, out, issiso=sys.issiso(), squeeze=squeeze)
return out
Expand Down