-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: better error message for shared axes and axis('equal') #21318
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
FIX: better error message for shared axes and axis('equal') #21318
Conversation
5b2ad5d
to
5d37e45
Compare
This PR is affected by a re-writing of our history to remove a large number of accidentally committed files see discourse for details. To recover this PR it will need be rebased onto the new default branch (main). There are several ways to accomplish this, but we recommend (assuming that you call the matplotlib/matplotlib remote git remote update
git checkout main
git merge --ff-only upstream/main
git checkout YOUR_BRANCH
git rebase --onto=main upstream/old_master
# git rebase -i main # if you prefer
git push --force-with-lease # assuming you are tracking your branch If you do not feel comfortable doing this or need any help please reach out to any of the Matplotlib developers. We can either help you with the process or do it for you. Thank you for your contributions to Matplotlib and sorry for the inconvenience. |
5d37e45
to
400445a
Compare
400445a
to
2ad34af
Compare
-- rebased |
lib/matplotlib/axes/_base.py
Outdated
raise RuntimeError("'equal' is not allowed on shared " | ||
"axes, try 'scaled' instead.") |
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.
Is the original exception important here, or should we do from None
here?
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.
Is it a RunTimeError that we want to re-raise here, or should we change it to ValueError
instead since you are saying that value isn't allowed?
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.
As above, I'm not sure I can even trigger this so lets try removing...
lib/matplotlib/axes/_base.py
Outdated
self.set_aspect('equal', adjustable='datalim') | ||
try: | ||
self.set_aspect('equal', adjustable='datalim') | ||
except RuntimeError: |
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.
We only want to catch the above exception, right? Technically, we should make sure not to catch other RuntimeErrors here, either by inspecting the message or by using a custom exception above.
But I'm not sure if we have to be that pedantic. Catching the wrong exception does not change control flow, it could only issue a non-instructive error message.
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.
OK, looking back at it now, I'm not sure what this is supposed to catch. set_aspect
does not call apply_aspect
, and apply_aspect
is only called at draw time so far as I can tell. I couldn't figure out a test for this, so lets see if anything fails just removing it again.
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.
Confirmed, this doesn't fail any tests - so I'm not even sure this was reachable. Sorry I don't remember what prompted this int he first place!
PR Summary
Closes #11416
The error message was pretty mysterious if you called
ax.axis('equal')
on a shared axes...Not clear that the functionality users are trying to get from this could not be provided, but at least clarifying the error message will help...
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).