[Numpy-discussion] Re: Unexpected return values for np.mod with x2=np.inf and similar

2024-06-10 Thread Matti Picus

What operating system?


If I recall correctly, NumPy tries to be compatible with CPython for 
these edge cases.



The actual implementation is a bit scattered. I think it would be nice 
if we could have an "explain" decorator to ufuncs that would return the 
name of the inner loop used in practice to aid in debugging and 
teaching. Until then your best bet is to build NumPy locally with debug 
information and use a debugger, but even that can be challenging at times.


Matti


On 07/06/2024 21:10, jesse.live...@gmail.com wrote:

Hi all,

I ran into an odd edge-case with np.mod and was wondering if this is the 
expected behavior, and if so why. This is on a fresh install of python 3.10.14 
with numpy 1.26.4 from conda-forge.
...
Any ideas why these are the return values? I had a hard time tracking down 
where in the numpy source np.mod was coming from.
Jesse
___
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: matti.pi...@gmail.com
https://github.com/numpy/numpy/blob/main/numpy/_core/src/umath/loops_modulo.dispatch.c.src#L557

___
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


[Numpy-discussion] Re: Unexpected return values for np.mod with x2=np.inf and similar

2024-06-10 Thread Sebastian Berg
On Mon, 2024-06-10 at 10:49 +0300, Matti Picus wrote:
> What operating system?
> 
> 
> If I recall correctly, NumPy tries to be compatible with CPython for 
> these edge cases.
> 

Right, and there seems nothing odd here to me.  Try using `divmod()` on
a few numbers (not infinities) to realize that this is how Python
defines things.
Python modulo is not identical to IEEE modulo as describd in the docs.

- Sebastian


> 
> The actual implementation is a bit scattered. I think it would be
> nice 
> if we could have an "explain" decorator to ufuncs that would return
> the 
> name of the inner loop used in practice to aid in debugging and 
> teaching. Until then your best bet is to build NumPy locally with
> debug 
> information and use a debugger, but even that can be challenging at
> times.
> 
> Matti
> 
> 
> On 07/06/2024 21:10, jesse.live...@gmail.com wrote:
> > Hi all,
> > 
> > I ran into an odd edge-case with np.mod and was wondering if this
> > is the expected behavior, and if so why. This is on a fresh install
> > of python 3.10.14 with numpy 1.26.4 from conda-forge.
> > ...
> > Any ideas why these are the return values? I had a hard time
> > tracking down where in the numpy source np.mod was coming from.
> > Jesse
> > ___
> > 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: matti.pi...@gmail.com
> > https://github.com/numpy/numpy/blob/main/numpy/_core/src/umath/loops_modulo.dispatch.c.src#L557
> ___
> 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


[Numpy-discussion] Next NumPy Newcomers' Hour - June 13th, 2023 at 12 PM UTC

2024-06-10 Thread Ganesh Kathiresan
Our next Newcomers' Hour will be held this Thursday, 13th, 2023 at 12 PM
UTC,  Stop by to ask questions, share your progress, celebrate success, or
just to say hi.

To add to the meeting agenda the topics you’d like to discuss, follow the
link: https://hackmd.io/3f3otyyuTte3FU9y3QzsLg?both.

Join the meeting via Zoom:
https://us06web.zoom.us/j/82563808729?pwd=ZFU3Z2dMcXBGb05YemRsaGE1OW5nQT09.

Thanks,
Ganesh
___
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