-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
dates
classes and functions support tz
both as string and tzinfo
#22196
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
720a681
to
280e7d1
Compare
doc/users/next_whats_new/datestr2num_list_with_default_date.rst
Outdated
Show resolved
Hide resolved
I have found some more issues, especially the matplotlib/lib/matplotlib/dates.py Lines 499 to 510 in 2f81a8b
but
This is somewhat consistent throughout the whole Two possible solutions:
Any preferences? I'm leaning towards 2 to not break the documentation (although it didn't work as stated). |
Another example: matplotlib/lib/matplotlib/dates.py Lines 657 to 658 in 2f81a8b
Stored as matplotlib/lib/matplotlib/dates.py Line 721 in 2f81a8b
Used as matplotlib/lib/matplotlib/dates.py Line 774 in 2f81a8b
But matplotlib/lib/matplotlib/dates.py Line 622 in 2f81a8b
|
OK, first the doc for concise formatter is wrong - it should say as "in num2date", not date2num. num2date takes only
So, what does Given the ambiguity in timezone names and what package can translate them, my tendency would be to tell users to supply |
Yes, I realized that. In the meanwhile I happened to implement the second approach: support both str and tzinfo. But I can change it to only support tzinfo and change the documentation to reflect that. (Right now I changed it to say both.) |
Looking at the diff there were three classes/functions that had an incorrect documentation w.r.t tz format: Just to confirm: it is OK to "break" this and only support tzinfo? (I can of course do the (Anyway, I need to focus on creating an exam, so there will be time to agree on the best solution. Just took a small break...) |
dates
classes and functions support tz
both as string and tzinfo
ad9eac5
to
f93514f
Compare
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.
Suggest being even more explicit about what strings are available. However, I'm not sure if datetutil will resolve in the numpydoc lookup?
d51b377
to
8e7c2b1
Compare
Check For example RRuleLocator in the list of date tickers here: https://matplotlib.org/stable/api/dates_api.html (I noted that rrulewrapper is not in the documentation, although it is linked there. Should I add it, remove the linking, or just leave it?) |
Great...
I think its strange to link it but not have it int he docs. Thanks for looking so carefully! |
I do not unfortunately understand why it does not show up... A guess is that everything in |
Some more insights, so I changed this and all other missing references in |
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.
Some minor suggestions, but this looks 👍
@@ -1,6 +1,6 @@ | |||
""" | |||
Matplotlib provides sophisticated date plotting capabilities, standing on the | |||
shoulders of python :mod:`datetime` and the add-on module :mod:`dateutil`. | |||
shoulders of python :mod:`datetime` and the add-on module dateutil_. |
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.
Could we add the dateutil intersphinx and leave the markup?
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 do not fully understand exactly how this works, but it was a way to get a proper link. Maybe there are better ways.
string. If you want to use a different timezone, pass the *tz* keyword | ||
argument of `num2date` to any date tickers or locators you create. This can | ||
be either a `datetime.tzinfo` instance or a string with the timezone name that | ||
can be parsed by `~dateutil.tz.gettz`. |
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.
can be parsed by `~dateutil.tz.gettz`. | |
can be parsed by `dateutil.tz.gettz`. |
This is outside of us so leave the full name?
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 do not remember the rationale for it, but I see the point. Will revert it (if it works).
I erred on the side of merging this despite my two minor documentation quibbles. |
string. If you want to use a different timezone, pass the *tz* keyword | ||
argument of `num2date` to any date tickers or locators you create. This can |
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.
This sentence no longer says the same thing. Previously it said to pass tz
to num2date
or the other options. Now it says to pass num2date
to the other options.
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 do not read it like that. To me it sounds more like "use the same tz argument that you passed to num2date". But I agree that it probably can be made clearer (obviously, as you read it differently).
(Btw, was suggested here: #22196 (comment) )
I can create a follow-up. |
PR Summary
Edit:
There were inconsistent use/documentation of the
tz
parameters indates
, where the documentation stated string in some cases, although onlytzinfo
was working. Now, both approaches do work (and there is even an error if thercParams
-provided string is not a valid time zone). See below for discussion.Original purpose: Added a bunch of tests for
dates.py
to increase coverage.In addition: Found an issue with
datestr2num
where passing a list and a defaultdatetime
object gives an error in currentmain
.results in
Do you use release notes for this type of minor bug fixes?
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).