Overloading A Float To A Numpy Array
I have a function, processing a 1D numpy array, like this: def f(arr): arr=asarray(arr) #process data as numpy array #... return arr With asarray I allow to call t
Solution 1:
I believe you are looking for np.atleast_1d
.
>>> np.atleast_1d(5)
array([5])
>>> np.atleast_1d(np.arange(2))
array([0, 1])
Post a Comment for "Overloading A Float To A Numpy Array"