Catch invalid interactive switch to log scale. #6983

Merged
merged 1 commit into from Aug 27, 2016

Conversation

Projects
None yet
6 participants
Contributor

anntzer commented Aug 26, 2016

plt.plot([1, 2], [-1, -2]) and press l (switch y to log-scale).
Before, this would crash the Qt5 backend and cause an invalid internal
state in others, due to the complete lack of positive values. Now a
warning is printed and the command is cancelled.

See #6852.

@anntzer anntzer Catch invalid interactive switch to log scale.
`plt.plot([1, 2], [-1, -2])` and press `l` (switch y to log-scale).
Before, this would crash the Qt5 backend and cause an invalid internal
state in others, due to the complete lack of positive values.  Now a
warning is printed and the command is cancelled.
c3e84b0

mdboom added the needs_review label Aug 26, 2016

Owner

jenshnielsen commented Aug 26, 2016

Makes sense to me. How does the warning look. Should we change it to something more user friendly?

Contributor

anntzer commented Aug 26, 2016

/home/antony/src/extern/matplotlib/lib/matplotlib/axes/_base.py:2276: RuntimeWarning: invalid value encountered in double_scalars
  delta = (x1t - x0t) * margin
/home/antony/src/extern/matplotlib/lib/matplotlib/backend_bases.py:2584: UserWarning: Data has no positive values, and therefore can not be log-scaled.
  warnings.warn(str(exc))

I think it's clear enough?

Owner

jenshnielsen commented Aug 26, 2016

Yes 👍

Looks good. I wasn't aware of the warnings module. Good to know!

@tacaswell tacaswell merged commit f95169e into matplotlib:master Aug 27, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.01%) to 70.189%
Details

tacaswell removed the needs_review label Aug 27, 2016

QuLogic added this to the 2.1 (next point release) milestone Aug 27, 2016

@tacaswell tacaswell added a commit that referenced this pull request Aug 27, 2016

@tacaswell tacaswell Merge pull request #6983 from anntzer/dont-crash-on-interactive-inval…
…id-log

FIX: Catch invalid interactive switch to log scale.
Conflicts:
	lib/matplotlib/backend_bases.py
  	   did not backport draw -> draw_idle change
ac01d85
Owner

tacaswell commented Aug 27, 2016

backported to v2.x as ac01d85

anntzer deleted the anntzer:dont-crash-on-interactive-invalid-log branch Sep 12, 2016

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