On Thu, 2023-04-20 at 13:59 -0400, Warren Weckesser wrote:
> On 4/20/23, Sebastian Berg <sebast...@sipsolutions.net> wrote:
> > Hi all,
> > 
> > 

<snip>

> 
> In [64]: np.float64(np.array([0.0]))
> <ipython-input-64-0f0309f2cf0c>:1: DeprecationWarning: Conversion of
> an array with ndim > 0 to a scalar is deprecated, and will error in
> future. Ensure you extract a single element from your array before
> performing this operation. (Deprecated NumPy 1.25.)
>   np.float64(np.array([0.0]))
> Out[64]: 0.0
> 
> In [65]: np.float64(np.array([0.0, 0.0]))
> Out[65]: array([0., 0.])
> 

Hmmmpf, that would be a good follow-up to fix.  In theory a
FutureWarning I guess (returning the array), but in practice, I think
we should just give the correct array result.

(I don't love returning arrays from scalar constructors, but that is
another thing and not for now.)

- Sebsatian


> ```
> 
> In 1.24.2, `np.float64(np.array([0.0])` returns the the scalar 0.0.
> 
> If passing arrays to `np.float64()` is intentionally supported, it
> seems it would be more consistent for `np.float64(np.array([0.0]))`
> to
> return `np.array([0.0])`.  That is how the other numpy types work
> (e.g. `np.complex128`, `np.int64`, etc.). But I'm not sure if there
> is
> a deprecation/update path that would get us there.
> 
> Warren
> 
> > 
> > _______________________________________________
> > NumPy-Discussion mailing list -- numpy-discussion@python.org
> > To unsubscribe send an email to numpy-discussion-le...@python.org
> > https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> > Member address: warren.weckes...@gmail.com
> > 
> _______________________________________________
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: sebast...@sipsolutions.net
> 


_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to