According to my understanding, with classes
instance.method(parameters)=class.method(instance,parameters), so it's just a notation difference.
But np.resize(ndarray) changes out_place, while ndarray.resize() changes in_place.
What am I missing?
Yes, but numpy isn't the class, it is the module. You want numpy.ndarray as the class. Observe:
In [1]: import numpy as np
In [2]: arr = np.array([1,2,3])
In [3]: np.ndarray.resize(arr, (3,1))
In [4]: arr
Out[4]:
array([[1],
[2],
[3]])
In [5]: np.ndarray.resize(arr, (3,))
In [6]: arr
Out[6]: array([1, 2, 3])
So, numpy.resize is just a module-level function, that returns a new array instead of modifying the array in-place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With