fix issue with multiplying MIMO LTI system by scalar by murrayrm · Pull Request #1078 · python-control/python-control
Expand Up
@@ -634,11 +634,11 @@ def __mul__(self, other):
from .statesp import StateSpace
# Convert the second argument to a transfer function. if isinstance(other, StateSpace): if isinstance(other, (StateSpace, np.ndarray)): other = _convert_to_transfer_function(other) elif isinstance(other, (int, float, complex, np.number, np.ndarray)): other = _convert_to_transfer_function(other, inputs=self.ninputs, outputs=self.noutputs) elif isinstance(other, (int, float, complex, np.number)): # Multiply by a scaled identity matrix (transfer function) other = _convert_to_transfer_function(np.eye(self.ninputs) * other) if not isinstance(other, TransferFunction): return NotImplemented
Expand Down Expand Up @@ -681,8 +681,8 @@ def __rmul__(self, other):
# Convert the second argument to a transfer function. if isinstance(other, (int, float, complex, np.number)): other = _convert_to_transfer_function(other, inputs=self.ninputs, outputs=self.ninputs) # Multiply by a scaled identity matrix (transfer function) other = _convert_to_transfer_function(np.eye(self.noutputs) * other) else: other = _convert_to_transfer_function(other)
Expand Down Expand Up @@ -723,9 +723,8 @@ def __truediv__(self, other): """Divide two LTI objects."""
if isinstance(other, (int, float, complex, np.number)): other = _convert_to_transfer_function( other, inputs=self.ninputs, outputs=self.ninputs) # Multiply by a scaled identity matrix (transfer function) other = _convert_to_transfer_function(np.eye(self.ninputs) * other) else: other = _convert_to_transfer_function(other)
Expand Down
# Convert the second argument to a transfer function. if isinstance(other, StateSpace): if isinstance(other, (StateSpace, np.ndarray)): other = _convert_to_transfer_function(other) elif isinstance(other, (int, float, complex, np.number, np.ndarray)): other = _convert_to_transfer_function(other, inputs=self.ninputs, outputs=self.noutputs) elif isinstance(other, (int, float, complex, np.number)): # Multiply by a scaled identity matrix (transfer function) other = _convert_to_transfer_function(np.eye(self.ninputs) * other) if not isinstance(other, TransferFunction): return NotImplemented
Expand Down Expand Up @@ -681,8 +681,8 @@ def __rmul__(self, other):
# Convert the second argument to a transfer function. if isinstance(other, (int, float, complex, np.number)): other = _convert_to_transfer_function(other, inputs=self.ninputs, outputs=self.ninputs) # Multiply by a scaled identity matrix (transfer function) other = _convert_to_transfer_function(np.eye(self.noutputs) * other) else: other = _convert_to_transfer_function(other)
Expand Down Expand Up @@ -723,9 +723,8 @@ def __truediv__(self, other): """Divide two LTI objects."""
if isinstance(other, (int, float, complex, np.number)): other = _convert_to_transfer_function( other, inputs=self.ninputs, outputs=self.ninputs) # Multiply by a scaled identity matrix (transfer function) other = _convert_to_transfer_function(np.eye(self.ninputs) * other) else: other = _convert_to_transfer_function(other)
Expand Down