The duplicate will respond what, but not adequately, whyor why it is not mentioned in the documents, even if it is required. Read on ...
There are two ways to create a deep copy of the numpy array. One way is to use copy.deepcopyfrom a module copy. Another way is to call array.__deepcopy__directly.
From docs :
ndarray.__deepcopy__() → Deep copy of array.
Used if copy.deepcopycalled in an array.
The docs suggest that the correct way to call this function is without arguments. However....
In [47]: x
Out[47]:
array([[1, 1],
[2, 2]])
In [48]: x.__deepcopy__()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-48-00c3b8eda618> in <module>()
----> 1 x.__deepcopy__()
TypeError: __deepcopy__() takes exactly 1 argument (0 given)
Coming backA TypeError! But...
In [51]: x.__deepcopy__(None)
Out[51]:
array([[1, 1],
[2, 2]])
And even...
In [52]: x.__deepcopy__([12345, 'blah blah'])
Out[52]:
array([[1, 1],
[2, 2]])
This function seems to require an argument, but this argument supposedly has nothing to do with the returned copy.
. ? , ?