Skip to content
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

Fixup of PR #4921 #4982

Merged
merged 2 commits into from Aug 23, 2014
Merged

Fixup of PR #4921 #4982

merged 2 commits into from Aug 23, 2014

Conversation

charris
Copy link
Member

@charris charris commented Aug 22, 2014

BUG: Fix NaN handling in npy_ObjectMax and npy_ObjectMin.

These functions currently fail randomly for Python < 3.x because they
use PyObject_Cmp, which looks at addresses for NaN objects. The fix is
to use PyObject_RichCompareBool, which is available in Python >= 2.6.
Note that for Python 2.6 and 2.7, PyObject_RichCompareBool falls back on
PyObject_Cmp when an object doesn't provide rich compare.

Closes #4903.

These functions currently fail randomly for Python < 3.x because they
use PyObject_Cmp, which looks at addresses for NaN objects. The fix is
to use PyObject_RichCompareBool, which is available in Python >= 2.6.
Note that for Python 2.6 and 2.7, PyObject_RichCompareBool falls back on
PyObject_Cmp when an object doesn't provide rich compare.

Closes numpy#4903.
@charris charris mentioned this pull request Aug 22, 2014
@juliantaylor
Copy link
Contributor

can you add a testcase?

There is a random element to these tests, so that they may fail to
fail when python compare is being used instead of richcompare.
@charris
Copy link
Member Author

charris commented Aug 22, 2014

Added. I note the numpy maximum/minimum for objects behaves differently than Python3 max/min.

@charris
Copy link
Member Author

charris commented Aug 23, 2014

OK, putting this in.

charris added a commit that referenced this pull request Aug 23, 2014
@charris charris merged commit 2059cce into numpy:master Aug 23, 2014
@charris charris deleted the gh-2941 branch August 23, 2014 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NaN handling in npy_ObjectMax() and npy_ObjectMin() in Python 2
3 participants