Additional I/O system type conversions by murrayrm · Pull Request #672 · python-control/python-control
This PR adds some type conversations for algebraic operations involving I/O systems, motivated by an example I was putting together where I wanted to generate a Nyquist plot for a linearized nonlinear I/O system (type LinearIOSystem) and a simple lead compensator (type TransferFunction). Using P * C generated a type conversation error but C * P was OK as was ct.tf(P) * C. It seemed annoying to have to do the explicit typecasting, so I decided to implement some of the operations that were needed to make P * C work (generates a LinearICSystem, which is a subclass of StateSpace).
The following functionality has been added:
- Added
__sub__, so that you can write G1 - G2 for I/O systems - Added conversions for scalars, arrays, state space, and transfer function systems so that they can be combined with I/O systems on either the left or right.
- Set the Numpy
__array_priority__value so that operations involving ndarrays are handled as I/O system operations and I/O system operations take precedence over LTI operations involving ndarrays.
I also did some PEP8 cleanup on iosys.py while I was at it, and put in unit tests for the code.