8000 correct behaviour for assert_array_less with inf/nan by AnishShah · Pull Request #7135 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

correct behaviour for assert_array_less with inf/nan #7135

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
wants to merge 1 commit into from
Closed

correct behaviour for assert_array_less with inf/nan #7135

wants to merge 1 commit into from

Conversation

AnishShah
Copy link

Fixes #2418

@AnishShah
Copy link
Author

@rgommers Can you please review this PR?

@@ -689,20 +689,13 @@ def chk_same_position(x_id, y_id, hasval='nan'):

if isnumber(x) and isnumber(y):
x_isnan, y_isnan = isnan(x), isnan(y)
x_isinf, y_isinf = isinf(x), isinf(y)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the motivation to remove the checks for +/-infinity (these lines and all the ones below)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous logic for assert_array_compare was if there was inf in x or y, it should be at the same location (array id). It just checks the location of inf, it does not do any sort of comparison, which is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just for my edification, you are relying on all of the following being true?

+inf == +inf
-inf == -inf
-inf < +inf
-inf < some_finite_number
some_finite_number < +inf

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnishShah
Copy link
Author

any review for this PR?

@charris charris added this to the 1.12.0 release milestone Apr 16, 2016
@charris
Copy link
Member
charris commented Jun 15, 2016

This is not correct, look at the compare function passed in assert_array_almost_equal and see that in the following a and b are almost equal.

In [1]: from numpy.testing import assert_array_almost_equal

In [2]: a = array([np.inf, -np.inf])

In [3]: b = array([-np.inf, np.inf])

In [4]: assert_array_almost_equal(a, b)

@charris charris removed this from the 1.12.0 release milestone Jun 15, 2016
@homu
Copy link
Contributor
homu commented Aug 28, 2016

☔ The latest upstream changes (presumably #7985) made this pull request unmergeable. Please resolve the merge conflicts.

@AnishShah AnishShah closed this Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0