Skip to content

numpy.ndarray * control.TransferFunction gives array object #459

@roryyorke

Description

@roryyorke

TransferFunction 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.]]))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy