- Notifications
You must be signed in to change notification settings - Fork441
Closed
Description
I spent quite a bit of time trying to debug an error and finally stumbled on the documentation:
# Beware: this is a shallow copy! This should be okay,# but be careful.
It took me a bit of digging and debugging before I realized my errors caused by the shallow copy:
>>> print(num)>>> print(type(num[0]))[[1], [2]]<class 'list'>>>> sys1 = control.TransferFunction([num],[den])>>> sys1>>> print(num)>>> print(type(num[0]))[array([1]), array([2])]<class 'numpy.ndarray'>
This can make scripts behave different based on the order of operation:
num = ...den = ...myfunc(num)TransferFunction(num, den)
vs.
num = ...den = ...TransferFunction(num, den)myfunc(num)
To new Python users having the variables 'num' & 'den' behave different before and after callingTransferFunction
can be confusing and off-putting.
Metadata
Metadata
Assignees
Labels
No labels