<div dir="ltr">numpy.asanyarray() would be my preferred goto, as it will leave subclasses of ndarray untouched; asarray() and atleast_1d() force ndarray. It's nice to do the whenever possible.<div><br></div><div>Ryan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 2, 2015 at 6:52 AM, Slavin, Jonathan <span dir="ltr"><<a href="mailto:jslavin@cfa.harvard.edu" target="_blank">jslavin@cfa.harvard.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Personally I like atleast_1d, which will convert a scalar into a 1d array but will leave arrays untouched (i.e. won't change the dimensions. Not sure what the advantages/disadvantages are relative to asarray.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Jon</div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 2, 2015 at 7:05 AM, <span dir="ltr"><<a href="mailto:numpy-discussion-request@scipy.org" target="_blank">numpy-discussion-request@scipy.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">From: Juha Jeronen <<a href="mailto:juha.jeronen@jyu.fi" target="_blank">juha.jeronen@jyu.fi</a>><br>To: Discussion of Numerical Python <<a href="mailto:numpy-discussion@scipy.org" target="_blank">numpy-discussion@scipy.org</a>><br>Cc: <br>Date: Fri, 2 Oct 2015 13:31:47 +0300<br>Subject: Re: [Numpy-discussion] Cython-based OpenMP-accelerated quartic polynomial solver<div><div class="h5"><br>
<div text="#000000" bgcolor="#FFFFFF">
On 02.10.2015 13:07, Daπid wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra"><br>
<div class="gmail_quote">On 2 October 2015 at 11:58, Juha
Jeronen <span dir="ltr"><<a href="mailto:juha.jeronen@jyu.fi" target="_blank">juha.jeronen@jyu.fi</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
</blockquote>
<br>
</span>
First version done and uploaded:<br>
<br>
<a href="https://yousource.it.jyu.fi/jjrandom2/miniprojects/trees/master/misc/polysolve_for_numpy" rel="noreferrer" target="_blank">https://yousource.it.jyu.fi/jjrandom2/miniprojects/trees/master/misc/polysolve_for_numpy</a><br>
</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">Small comment: now you are checking if
the input is a scalar or a ndarray, but it should also accept
any array-like. If I pass a list, I expect it to work,
internally converting it into an array. <br>
</div>
</div>
</blockquote>
<br>
Good catch.<br>
<br>
Is there an official way to test for array-likes? Or should I always
convert with asarray()? Or something else?<br>
<br>
<br>
-J<br></div></div></div></div></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr">________________________________________________________<br>Jonathan D. Slavin Harvard-Smithsonian CfA<br><a href="mailto:jslavin@cfa.harvard.edu" target="_blank">jslavin@cfa.harvard.edu</a> 60 Garden Street, MS 83<br>phone: <a href="tel:%28617%29%20496-7981" value="+16174967981" target="_blank">(617) 496-7981</a> Cambridge, MA 02138-1516<br>cell: <a href="tel:%28781%29%20363-0035" value="+17813630035" target="_blank">(781) 363-0035</a> USA<br>________________________________________________________<br><br></div></div></div></div>
</font></span></div></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Ryan May<br><br></div></div></div>
</div>