Skip to content

Trying to set the labels without setting ticks through pyplot now raises TypeError*#15927

Merged
anntzer merged 1 commit into
matplotlib:masterfrom
rscmendes:throw-error-on-empty-ticks-for-issue-15005
Dec 16, 2019
Merged

Trying to set the labels without setting ticks through pyplot now raises TypeError*#15927
anntzer merged 1 commit into
matplotlib:masterfrom
rscmendes:throw-error-on-empty-ticks-for-issue-15005

Conversation

@rscmendes

Copy link
Copy Markdown

PR Summary

This PR was suggested in issue #15005 as to fix the error that is returned when xticks() or yticks() is called with only the labels as parameters. It is also a follow up from PR #15788.

Previously, passing labels without passing the ticks to either pyplot.xticks() and pyplot.yticks() would result in TypeError: object of type 'NoneType' has no len(). With this PR it now returns:
AttributeError: Labels can't be set without setting ticks.

PS: apologies for the delay.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Comment thread lib/matplotlib/pyplot.py Outdated
@rscmendes rscmendes force-pushed the throw-error-on-empty-ticks-for-issue-15005 branch from d963707 to 274fbdc Compare December 14, 2019 00:36
@rscmendes rscmendes changed the title Trying to set the labels without setting ticks through pyplot now raises AttributeError Trying to set the labels without setting ticks through pyplot now raises TypeError* Dec 14, 2019

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Commits should be squashed.

@timhoffm timhoffm added API: changes Changes to the public API, typically requiring deprecation. API: argument checking Validation of acceptable argument values labels Dec 15, 2019
@timhoffm timhoffm added this to the v3.3.0 milestone Dec 15, 2019

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should get an entry in doc/api/next_api_changes/behavior.rst.

Comment thread lib/matplotlib/pyplot.py Outdated
Comment thread lib/matplotlib/pyplot.py Outdated
@rscmendes rscmendes force-pushed the throw-error-on-empty-ticks-for-issue-15005 branch from 274fbdc to a9ebd40 Compare December 15, 2019 14:31
@rscmendes

Copy link
Copy Markdown
Author

Sorry for the flask8 compliance issue, thought it was OK with 80 but should've tested -- still have a lot to learn. Should be good now.

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! From my side, this is good to go. Waiting for a second positive review.

Commits should still be squashed. Can be done by the author locally + force-push; or if you're not that familiar with git, we'll squash through the github interface when merging.

Comment thread doc/api/next_api_changes/behaviour.rst Outdated
@rscmendes rscmendes force-pushed the throw-error-on-empty-ticks-for-issue-15005 branch from a9ebd40 to 86dd139 Compare December 16, 2019 00:23
@anntzer

anntzer commented Dec 16, 2019

Copy link
Copy Markdown
Contributor

Thanks for the PR, hoping to see you around again :)

@anntzer anntzer merged commit 03b255d into matplotlib:master Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API: argument checking Validation of acceptable argument values API: changes Changes to the public API, typically requiring deprecation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants