Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
numpy.ndarray * control.TransferFunction gives array object #459
Comments
|
My two cents:
For the specific case above, I would have expected to get a |
|
I think that the result of a mathematical operation between two mathematical objects should have a type that is a superset of the two types (like casting an int into a float when multiplying by a float). If you think of a transfer function as a frequency-dependent gain, then I agree that the output should be a transfer function too. |
|
For the purposes of being able to use For the operations +, -, *, /, I would expect the following priority of "type conversion", where conversions are always to earlier entries (so, e.g., FRD + StateSpace should give type FRD). For FRD, this is based on the idea that it's possible, and least in principle, to go from any of the others to FRD type, but the opposite is not possible (or, at least, not straightforward).
However, some command-line experimentation found this is not the case. Results below (script after that), showing the result type of Not all operations are defined (many "E" s), and the tables are frequently not symmetric about the diagonal. Division is a special case: it probably only makes sense to divide by a tf or frd. (And frd / anything also makes sense). We don't support matmul at all; ignore that part of the table.
|
|
This is great. I knew that ss/float gave an error and was thinking about a PR, but this shows that there are a few holes to fill. This hierarchy makes sense to me. Should a |
That seems right; and, operations trying to combine these two should fail. There's also |
|
|
TransferFunctiondoesn't have the__array_priority = 11class attribute thatStateSpaceandFrequencyResponseDatado. Is this on purpose? See below for results ofarray * tf, which results in an array (dtype object), andarray * ss, which results in a SS object. I found this while investigating the behaviour ofbdalg.connectin relation with #421Should 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?)