Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Print incorrect tz argument in error message #25420

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
oscargus merged 1 commit into matplotlib:main from oscargus:printincorrecttz
Mar 9, 2023

Conversation

Copy link
Member

@oscargus oscargus commented Mar 9, 2023

PR Summary

Related to #25419.

It would have been slightly easier to realize that something surprising was going on if one could have seen the incorrectly passed tz argument (which was not the one that a user would expect that they had just passed...).

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

valeriupredoi reacted with rocket emoji
@tacaswell tacaswell added this to the v3.8.0 milestone Mar 9, 2023
Copy link
Member

ksunden commented Mar 9, 2023

Anyone can merge post CI

@@ -230,7 +230,7 @@ def _get_tzinfo(tz=None):
return tzinfo
if isinstance(tz, datetime.tzinfo):
return tz
raise TypeError("tz must be string or tzinfo subclass.")
raise TypeError(f"tz must be string or tzinfo subclass, not {tz!r}.")
Copy link
Member

@jklymak jklymak Mar 9, 2023

Choose a reason for hiding this comment

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

I think this is good, but perhaps more fundamentally is that dates.py does not define allowable units...

Copy link
Member Author

@oscargus oscargus Mar 9, 2023

Choose a reason for hiding this comment

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

Yes, there seems to be a bit of "abuse" of things. This line doesn't really look like one would hope for:

To me it seems like one is patching dates to, sort of, work with units. But then I have very limited insights into how the units do work.

There can for sure be better fixes for this, but this one the one I could add to at least improve the situation slightly...

My interpretation of the problem is that there is no checking for validity when setting the units. Then, when setting timezone through axis_date, whatever is set as self.units of the Axis is used and an AutoDateLocator is instantiated with that as tz...

@oscargus oscargus merged commit 3810c29 into matplotlib:main Mar 9, 2023
@oscargus oscargus deleted the printincorrecttz branch March 9, 2023 22:32
Copy link

great, very many thanks @oscargus and co! Can probably close #25419 now, but I'll let that up to you guys 👍

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

@jklymak jklymak jklymak left review comments

@tacaswell tacaswell tacaswell approved these changes

@ksunden ksunden ksunden approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /