When I use the empty_like
numpy function , I got 1 error and could not explain it myself.
Here is the code:
In [38]: aa=np.array([1,2])
In [39]: b=np.empty_like(aa)
In [40]: b=np.empty_like(a=aa)
TypeError
Traceback (most recent call last)
<ipython-input-40-9b39ff78d8bb> in <module>()
TypeError: Required argument 'prototype' (pos 1) not found
I looked at the documentation that says
empty_like(a, dtype=None, order='K', subok=True)
Returns a new array with the same shape and type as the given array.
...
What is the reason? A function has a formal parameter with a name a
, but I cannot use it to call a function. Of course, this is normal for another * _like function with a
.
In [42]: b=np.zeros_like(a=aa)
In [43]: b=np.ones_like(a=aa)
Does anyone know the reason? Or is it a mistake?
source
share