<div dir="auto"><div>On minor thing that instead of 'ret' there should be 'x'.</div><div dir="auto"><br></div><div dir="auto">With kind regards, -gdg</div><div dir="auto"><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On Dec 12, 2017 22:51, "Joe" <<a href="mailto:solarjoe@posteo.org">solarjoe@posteo.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
the best example I found was this one:<br>
<br>
<a href="https://stackoverflow.com/a/29319864/7919597" rel="noreferrer" target="_blank">https://stackoverflow.com/a/29<wbr>319864/7919597</a><br>
<br>
def func_for_scalars_or_vectors(x)<wbr>:<br>
    x = np.asarray(x)<br>
    scalar_input = False<br>
    if x.ndim == 0:<br>
        x = x[None]  # Makes x 1D<br>
        scalar_input = True<br>
<br>
    # The magic happens here<br>
<br>
    if scalar_input:<br>
        return np.squeeze(ret)<br>
    return ret<br>
<br>
Is this as good as it gets or do you have other suggestions?<br>
<br>
Cheers,<br>
Joe<br>
______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/numpy-discussion</a><br>
</blockquote></div><br></div></div></div>