[Numpy-discussion] Cython-based OpenMP-accelerated quartic polynomial solver

Ryan May rmay31 at gmail.com
Fri Oct 2 10:18:16 EDT 2015


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.

Ryan

On Fri, Oct 2, 2015 at 6:52 AM, Slavin, Jonathan <jslavin at cfa.harvard.edu>
wrote:

> ​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.
>
> Jon​
>
>
> On Fri, Oct 2, 2015 at 7:05 AM, <numpy-discussion-request at scipy.org>
> wrote:
>
>> From: Juha Jeronen <juha.jeronen at jyu.fi>
>> To: Discussion of Numerical Python <numpy-discussion at scipy.org>
>> Cc:
>> Date: Fri, 2 Oct 2015 13:31:47 +0300
>> Subject: Re: [Numpy-discussion] Cython-based OpenMP-accelerated quartic
>> polynomial solver
>>
>> On 02.10.2015 13:07, Daπid wrote:
>>
>>
>> On 2 October 2015 at 11:58, Juha Jeronen <juha.jeronen at jyu.fi> wrote:
>>
>>>
>>>>
>>> First version done and uploaded:
>>>
>>>
>>> https://yousource.it.jyu.fi/jjrandom2/miniprojects/trees/master/misc/polysolve_for_numpy
>>>
>>
>> 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.
>>
>>
>> Good catch.
>>
>> Is there an official way to test for array-likes? Or should I always
>> convert with asarray()? Or something else?
>>
>>
>>  -J
>>
>
>
>
>
> --
> ________________________________________________________
> Jonathan D. Slavin                 Harvard-Smithsonian CfA
> jslavin at cfa.harvard.edu       60 Garden Street, MS 83
> phone: (617) 496-7981       Cambridge, MA 02138-1516
> cell: (781) 363-0035             USA
> ________________________________________________________
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


-- 
Ryan May
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20151002/dc040a65/attachment.html>


More information about the NumPy-Discussion mailing list