[Numpy-discussion] Re: Writing an array subclass in a compiled language with proper dispatch

2022-01-10 Thread Juan Luis Cano Rodríguez
On January 11, 2022, Sebastian Berg wrote: > On Mon, 2022-01-10 at 15:25 -0800, Stephan Hoyer wrote: > > There are no C-level APIs for __array_function__ or __array_ufunc__, > > so > > yes, at a high-level Python methods will be invoked by NumPy. > >  > > That said, NumPy's logic for handling __ar

[Numpy-discussion] Re: Writing an array subclass in a compiled language with proper dispatch

2022-01-10 Thread Sebastian Berg
On Mon, 2022-01-10 at 15:25 -0800, Stephan Hoyer wrote: > There are no C-level APIs for __array_function__ or __array_ufunc__, > so > yes, at a high-level Python methods will be invoked by NumPy. > > That said, NumPy's logic for handling __array_function__ and > __array_ufunc__ methods is written

[Numpy-discussion] Re: Writing an array subclass in a compiled language with proper dispatch

2022-01-10 Thread Stephan Hoyer
There are no C-level APIs for __array_function__ or __array_ufunc__, so yes, at a high-level Python methods will be invoked by NumPy. That said, NumPy's logic for handling __array_function__ and __array_ufunc__ methods is written in highly optimized C. If you wrote your own __array_function__ and

[Numpy-discussion] Writing an array subclass in a compiled language with proper dispatch

2022-01-10 Thread Juan Luis Cano Rodríguez
Hi all, I am a long time user of astropy.units, which allows one to define quantities with physical units as follows: >>> from astropy import units as u >>> 10 << u.cm >>> np.sqrt(4 << u.m ** 2) >>> ([1, 1, 0] << u.m) @ ([0, 10, 20] << u.cm / u.s) >>> (([1, 1, 0] << u.m) * ([0, 10, 20] << u.cm

[Numpy-discussion] Re: representation of valid float type range

2022-01-10 Thread Eric Moore
On Mon, Jan 10, 2022 at 7:15 AM Hameer Abbasi wrote: > Hello all. > > I believe that over the years there were multiple proposals to replace the > linspace formula start + n *(stop - start) / (npoints - 1) with a * start + > b * end with a, b linearly spaced between 0 and 1 with npoints. Concrete

[Numpy-discussion] Re: representation of valid float type range

2022-01-10 Thread Klaus Zimmermann
Hello, perhaps it would be best to have an issue about this on github? It might be worth pointing out that the original problem triggers a floating point error that can be caught and handled via errstate. This might be used either in linspace itself, or, if you think this rare problem is like

[Numpy-discussion] Re: representation of valid float type range

2022-01-10 Thread Hameer Abbasi
Hello all. I believe that over the years there were multiple proposals to replace the linspace formula start + n *(stop - start) / (npoints - 1) with a * start + b * end with a, b linearly spaced between 0 and 1 with npoints. Concretely, a = n / (npoints - 1), b = 1 - a. Here, 0 <= n < npoints.

[Numpy-discussion] Re: representation of valid float type range

2022-01-10 Thread alejandro . giacometti
I see what you mean, there is, however, some inconsistency on how this is handled, and it's not entirely intuitive ``` _type=np.int8 N=8 np.linspace( start=np.iinfo(_type).min, stop=np.iinfo(_type).max, num=N, dtype=_type, ) =>array([-128, -92, -56, -19, 17, 54, 90,