Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Patch to fix behavior of numpy.sign(numpy.nan) (Trac #794) #1392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
numpy-gitbot opened this issue Oct 19, 2012 · 8 comments
Closed

Patch to fix behavior of numpy.sign(numpy.nan) (Trac #794) #1392

numpy-gitbot opened this issue Oct 19, 2012 · 8 comments

Comments

@numpy-gitbot
Copy link

Original ticket http://projects.scipy.org/numpy/ticket/794 on 2008-05-17 by trac user brorson, assigned to @charris.

As was discussed on numpy-discuss earlier today, I am submitting a patch to fix the behavior of numpy.sign(numpy.nan). With this patch, the following behavior obtains:

>>> R = numpy.array([-numpy.inf, -2, 0, 2, numpy.inf, numpy.nan])
>>> numpy.sign(R)
array([ -1.,  -1.,   0.,   1.,   1.,  NaN])
>>>
>>> C = numpy.array([-numpy.inf, -2+1j, 0, 2-1j, numpy.inf, numpy.nan])
>>> numpy.sign(C)
array([ -1.+0.j,  -1.+0.j,   0.+0.j,   1.+0.j,   1.+0.j,  NaN+0.j])

Cheers,

Stuart Brorson[[BR]]
Interactive Supercomputing, inc.[[BR]]
135 Beaver Street | Waltham | MA | 02452 | USA[[BR]]
http://www.interactivesupercomputing.com/[[BR]]

@numpy-gitbot
Copy link
Author

@charris wrote on 2008-05-17

I will fix this in 1.2, not sooner. I have cleanups on queue for umathmodule and I don't want to complicate the merge.

@numpy-gitbot
Copy link
Author

Attachment added by trac user brorson on 2008-05-17: NumPy_NAN.diff

@numpy-gitbot
Copy link
Author

Milestone changed to 1.2.0 by @charris on 2008-05-17

@numpy-gitbot
Copy link
Author

@charris wrote on 2008-07-20

Applied, but NAN doesn't work on MSVC. I replaced it with x when isnan(x) tested true.

@numpy-gitbot
Copy link
Author

@charris wrote on 2008-07-21

This patch requires fixing some conversions of NaN to at least integer types. I've reverted the fix until all the implications can be worked out.

@numpy-gitbot
Copy link
Author

@cournape wrote on 2009-03-02

Will you have time to look at it for 1.3.0 ? If not, change to what you think is best

@numpy-gitbot
Copy link
Author

@charris wrote on 2009-03-10

IIRC, there was some discussion of what should be returned as the sign of nan. Currently it is zero for all inexact types. We could also return the sign bit, or just return nan. Maybe we should bring this up on the list again.

@numpy-gitbot
Copy link
Author

@charris wrote on 2009-03-10

As of r6621,r6624 the sign of real or complex nans is nan.
The Logical value of nan is True. Note that the integer value of nan remains 0 which conflicts with the logical value of nan. We may want to start raising exceptions when nan is cast to an integer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant