-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Make sure circular contours don't throw a warning #8574
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
Conversation
|
You can numpy.errstate to change how this is handled. https://docs.scipy.org/doc/numpy/reference/generated/numpy.errstate.html |
Check that warning isn't thrown for circular contours Ignore divide by zero warning
|
Hmm, looks like the windows build with python 2.7 and numpy 1.8 is throwing 4 warnings where there should be none on my new test. |
|
The warnings are coming from the I am confused why none of the other configuration raise it. Appveyor is using |
|
I've added another error ignore statement to catch that error - it seems to be raising when |
lib/matplotlib/contour.py
Outdated
| dist = np.add.reduce(([(abs(s)[i] / L[i]) for i in range(xsize)]), -1) | ||
| # Ignore warning that divide by zero throws, as this is a valid option | ||
| with np.errstate(divide='ignore', invalid='ignore'): | ||
| dist = np.add.reduce(([(abs(s)[i] / L[i]) for i in range(xsize)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra parentheses.
Is this abs(s[:, np.newaxis]) / L[np.newaxis, :] or abs(s[np.newaxis, :]) / L[:, np.newaxis]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? I don't think I've done anything on this line apart from move the -1) on to the next line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the first suggestion is just cleanup. The second is a question for my curiosity if you happen to know the answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea - I tried to understand what was going on here for a while but gave up...
Fixes #8529. This feels very hacky though - is there a better way to make division by zero return np.inf and not raise a warning?