[Numpy-discussion] What is the pythonic way to write a function that handles arrays and scalars?
kirillbalunov at gmail.com
Tue Dec 12 15:00:40 EST 2017
On minor thing that instead of 'ret' there should be 'x'.
With kind regards, -gdg
On Dec 12, 2017 22:51, "Joe" <solarjoe at posteo.org> wrote:
the best example I found was this one:
x = np.asarray(x)
scalar_input = False
if x.ndim == 0:
x = x[None] # Makes x 1D
scalar_input = True
# The magic happens here
Is this as good as it gets or do you have other suggestions?
NumPy-Discussion mailing list
NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion