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

Skip to content

BUG:warn on Nan in minimum,maximum for scalars, float16 #11595

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

Merged
merged 1 commit into from
Aug 1, 2018

Conversation

mattip
Copy link
Member

@mattip mattip commented Jul 20, 2018

Fixes #11589

PR #11043 added a check for Nan in the minimum, maximum loops.

Scalars and float16 take a different code path through maximum, minimum that was not checked. Tests added that failed before and pass after the fix.

Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

Single CI test failure on posix and windows involving np.maximum and float16 is probably related.

@mattip mattip force-pushed the warn-scalar-minimum branch from a468867 to 08ddc73 Compare July 22, 2018 07:04
@mattip
Copy link
Member Author

mattip commented Jul 22, 2018

Removed code that emits a warning on float16, if desired that should be a separate PR

@charris charris added this to the 1.15.1 release milestone Jul 22, 2018
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Jul 22, 2018
@seberg
Copy link
Member

seberg commented Jul 23, 2018

The float16 warnings still seem to show up in the tests?

@mattip mattip force-pushed the warn-scalar-minimum branch from 08ddc73 to 34074ac Compare July 23, 2018 22:02
@codecov-io
Copy link

codecov-io commented Jul 23, 2018

Codecov Report

Merging #11595 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11595      +/-   ##
==========================================
+ Coverage    85.7%    85.7%   +<.01%     
==========================================
  Files         327      327              
  Lines       81985    81987       +2     
==========================================
+ Hits        70264    70266       +2     
  Misses      11721    11721
Impacted Files Coverage Δ
numpy/core/tests/test_umath.py 99.56% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19522e2...b63687b. Read the comment docs.

with suppress_warnings() as sup:
sup.record(RuntimeWarning)
np.minimum(np.nan, 1)

Copy link
Member

Choose a reason for hiding this comment

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

assert_warns should be fine here? But the test does not actually check that the one warning is recorded like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@mattip mattip force-pushed the warn-scalar-minimum branch from 34074ac to b63687b Compare July 24, 2018 00:27
@charris
Copy link
Member

charris commented Jul 31, 2018

What was the problem with float16?

@mattip
Copy link
Member Author

mattip commented Aug 1, 2018

float16 never emit a npy_set_floatstatus_invalid in np.maximum, np.minimum even if Nan appears, unlike other floats. In the original PR I added npy_set_floatstatus_invalid to the HALF_{maximum, minimum} loops, but this goes beyond the original issue and changes current behavior, so I removed it in a subsequent changeset

@charris
Copy link
Member

charris commented Aug 1, 2018

@mattip Sounds like float16 should raise a warning just to be consistent, what is the argument against that?

@seberg
Copy link
Member

seberg commented Aug 1, 2018

I thought the argument was: "lets not go there for a minor release"? then again, it might have been, lets put in the quick bug fix before the release happens at the time.

I definitely agree that we should enable the warnings for float16, but I would say that now that 15.0 is out, it is simplest to just wait for the next release for the float16 part (I assume the float32 is partially a regression here), it is not a huge deal and has been buggy forever.

@mattip
Copy link
Member Author

mattip commented Aug 1, 2018

See PR #11660 which extends this for 1.16 (no backport of that PR needed)

@charris charris merged commit 76d74c3 into numpy:master Aug 1, 2018
@charris
Copy link
Member

charris commented Aug 1, 2018

Thanks Matti.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Aug 1, 2018
@charris charris removed this from the 1.15.1 release milestone Aug 1, 2018
@mattip mattip deleted the warn-scalar-minimum branch March 4, 2019 13:16
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.

missing invalid warning on nan comparisons?
5 participants