[Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Nico Schlömer
Hi everyone, This is seeking input on PR [1] which I've worked on with @eric-wieser and @seberg. It deprecates ``` float(x) ``` if `x` is an array of ndim > 0. (It works with all arrays of size 1 right now.) This aligns the behavior of float() on ndarrays with float() on lists which already fails

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread george trojan
Responding to the post by nico.schloe...@gmail.com (I subscribe to the digest). I just wrote the following code: twb = scipy.optimize.fsolve(phi, tdb, args=(tdb, p, w, hd_tdb, hg_tdb), xtol=1e-8) tdb, p, w, hd_tdb, hg_tdb twb.shape print("wet-bulb temperature {:.5f} [deg K]".format(float(twb)))

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Stephan Hoyer
On Wed, Sep 15, 2021 at 5:18 AM Nico Schlömer wrote: > Hi everyone, > > This is seeking input on PR [1] which I've worked on with @eric-wieser > and @seberg. It deprecates > ``` > float(x) > ``` > if `x` is an array of ndim > 0. (It works with all arrays of size 1 > right now.) This aligns the be

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Hameer Abbasi
Hello Nico, Any step in the direction of consistency and type safety is a good one to me. I’m +1 on this change. Best regards, Hameer Abbasi > Am 15.09.2021 um 14:18 schrieb Nico Schlömer : > > Hi everyone, > > This is seeking input on PR [1] which I've worked on with @eric-wieser > and @sebe

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Sebastian Berg
On Wed, 2021-09-15 at 17:25 +, george trojan wrote: > Responding to the post by nico.schloe...@gmail.com (I subscribe to > the > digest). > > I just wrote the following code: > > twb = scipy.optimize.fsolve(phi, tdb, args=(tdb, p, w, hd_tdb, > hg_tdb), > xtol=1e-8) > tdb, p, w, hd_tdb, hg_tdb

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Andrew Nelson
On Thu, 16 Sep 2021, 03:25 george trojan, wrote: > > I just wrote the following code: > > twb = scipy.optimize.fsolve(phi, tdb, args=(tdb, p, w, hd_tdb, hg_tdb), > xtol=1e-8) > tdb, p, w, hd_tdb, hg_tdb > twb.shape > print("wet-bulb temperature {:.5f} [deg K]".format(float(twb))) > > The output i

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Aaron Meurer
Presumably this also changes int(), bool(), and complex() in the same way. The array API standard (and numpy.array_api) only requires float(), bool(), and int() (and soon complex()) for dimension 0 arrays (the standard does not have scalars), in part because of this NumPy issue https://data-apis.o

Re: [Numpy-discussion] graphic design contribution to NumPy

2021-09-15 Thread Inessa Pawson
Hi, Vasiliy! It would be great if the infographic embraces the flat design principles and echoes the style of other graphic elements of the website. Let’s continue this conversation on GitHub, in the comments for the issue #435 . On Tue, Sep 14, 2021

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread george trojan
To Andrew Nelson: > In the return section for fsolve the documentation states that the return > value, `x`, is an `ndarray`. True, my bad. There is another issue with `fsolve`: it implicitly changes the argument passed to `func`. Consider def func(x): # x = float(x) if not np.isscalar(x

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Nico Schlömer
@george trojan The SciPy devs are very careful not to break backwards compatibility, even if the changes are arguably useful. That's why the impact of the numpy PR remains under the hood for SciPy users. I'd love to see SciPy become more consistent with array dimensionality, too, but that's a diff

Re: [Numpy-discussion] deprecating float(x) for ndim > 0

2021-09-15 Thread Nico Schlömer
> I was playing with this though and was a little surprised to find > NumPy allows things like this: > > >>> a = np.array([1, 2, 3]) > >>> a[:] = np.array([[[5, 6, 7]]]) > >>> a > array([5, 6, 7]) Thanks Aaron for this example! I hadn't seen this before, and indeed the suggested PR doesn't interce