- Notifications
You must be signed in to change notification settings - Fork441
Description
Proposal: When computing frequency and time response output of systems, standardize on indexing first element so output is a 1D array if system is SISO andsqueeze=True
. This is instead of applyingnumpy.squeeze
to output.
Currently, there are two ways that python-control squeezes output:
apply 'squeeze' to the output at the end. This is what functions in
timeresp.py
do, e.g.forced_response
(edit: andiosys
time responses). An m x n MIMO system (m-output, n-input, m,n>1) produces a [m x n x k] array, where k is the number of data points in time. But a 1 x n system's output gets squeezed to [n x k] and a m x 1 is squeezed to [m x k].use indexing to extract the first element if SISO, otherwise leave a full array. This is what the frequency response functions
evalfr
,freqresp
do. If SISO, give [k] length array; MIMO systems always produce [m x n x k] arrays.
I propose to standardize on the latter: a MIMO system should always output [m x n x k] arrays. Rationale: this facilitates interconnection and keeps indexing the system and its outputs consistent. Along with the proposal: retain thesqueeze=True
keyword argument because it's already in use, but do the 'squeeze' by indexing the first element, and only do it if SISO.
Documentation would read something like:
"If squeeze is True (default) and sys is single input single output (SISO), returns a 1D array equal to the length k of the input, otherwise returns an (n_outputs, n_inputs, k) array for multiple input multiple output (MIMO) systems."