numpy.ndarray * control.TransferFunction gives array object
See original GitHub issueTransferFunction doesn’t have the __array_priority = 11 class attribute that StateSpace and FrequencyResponseData do. Is this on purpose? See below for results of array * tf, which results in an array (dtype object), and array * ss, which results in a SS object. I found this while investigating the behaviour of bdalg.connect in relation with #421
Should multiplication of scalar transfer functions by arrays be special-cased so that, e.g., with scalar tf k, k * eye(5) gives a 5x5 TF with identical entries on the diagonal? I think this sort of convention is used in literature, but it might be tricky to get something consistent here (e.g., should 1-input 1-output state-space systems do something analogous?; should one do general broadcasting?)
(control-dev) rory@rory-latitude:~/src/python-control$ ipython
Python 3.8.5 | packaged by conda-forge | (default, Jul 31 2020, 02:39:48)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.17.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: !git describe
0.8.3-62-g6ede92e
In [2]: import control
In [3]: import numpy as np
In [4]: np.array([[1]]) * control.tf([1], [1,1])
Out[4]: array([[TransferFunction(array([1.]), array([1, 1]))]], dtype=object)
In [5]: np.array([[1]]) * control.ss([[-1]], [[1]], [[1]], [[0]])
Out[5]: StateSpace(array([[-1.]]), array([[1.]]), array([[1.]]), array([[0.]]))
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)

Top Related StackOverflow Question
My two cents:
As much as possible, it seems like all
LTIobjects should behave the same with respect to various operations. So it shouldn’t matter if you have aTransferFunctionor aStateSpacesystem of an LTI system.It also seems to me that if a control system object (
LTIorInputOutputSystem) is in an expression where you would expect to get back a control system object, things should work as expected. This basically prioritizes thecontrolobjects overnumpyobjects (I think).For the specific case above, I would have expected to get a
TransferFunctionback. I’d be interested to hear what others things about this.LinearIOSystemandInterconnectedSystemsare both subclasses ofInputOutputSystem. Any operation with anLTIsystem that can be converted to aStateSpacesystem can (and probably should) be promoted to anInputOutputsystem. Note that you can’t combine anFRDsystem with anInputOutputSystemsince the former is has (only) a frequency domain representation and later has (only) a state space representation.