Movatterモバイル変換


[0]ホーム

URL:


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

DOC: Add Date Tick Locators and Formatters example#21874

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:mainfromStefRe:date_fmt-loc_reference
Dec 7, 2021

Conversation

StefRe
Copy link
Contributor

PR Summary

Add Date Tick Locators and Formatters example.Closes#17283.

I noticed that

classrrulewrapper:
def__init__(self,freq,tzinfo=None,**kwargs):
has no docstring and hence can't be referred to in the documentation (seeadmonition:: References; the same pertains to
* `RRuleLocator`: Locate using a `matplotlib.dates.rrulewrapper`.
).

grafik


grafik

PR Checklist

Tests and Styling

  • [N/A] Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@jklymakjklymak added this to thev3.6.0 milestoneDec 6, 2021
Copy link
Member

@dstansbydstansby left a comment

Choose a reason for hiding this comment

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

This looks great! Usingeval() seems a bit odd to me - is there a reason thatlocators andformatters can't contain the actual locator/formatter instances instead of their eval strings?

jklymak reacted with thumbs up emoji
@StefRe
Copy link
ContributorAuthor

StefRe commentedDec 7, 2021
edited
Loading

@dstansby theeval is just to prevent redundant definition of the string 'AutoDateLocator(maxticks=8)'and the locator itself, i.e. it's meant as a shortcut of writing e.g.

locators = [    ('AutoDateLocator(maxticks=8)', AutoDateLocator(maxticks=8), '2003-02-01', '%Y-%m'),    ...

Maybe usingeval is not really best practice but it reduces the possibility of mistakes/inconsistencies between the code and the text in this case.

@jklymak
Copy link
Member

I guess I but the argument that theeval is useful here...

@story645
Copy link
Member

story645 commentedDec 7, 2021
edited
Loading

Maybe usingeval is not really best practice but it reduces the possibility of mistakes/inconsistencies between the code and the text in this case.

Would a repr on the objects (assuming it exists) print anything different from the eval?

@StefRe
Copy link
ContributorAuthor

@story645repr(AutoDateLocator(maxticks=8)) gives'<matplotlib.dates.AutoDateLocator object at 0x000001CE4F687CA0>'.

Defining nicereprs wouldn't be enough, however, as we also need the arguments of the function calls.

@story645
Copy link
Member

Defining nice reprs wouldn't be enough, however, as we also need the arguments of the function calls.

Why couldn't those be in the repr?

@StefRe
Copy link
ContributorAuthor

@story645
I only have very basic knowledge of python in this respect, maybe I'm completely wrong:

When I tryAutoDateLocator.__repr__ = lambda self: f'AutodateLocator(maxticks={self.maxticks})' thenrepr(AutoDateLocator(maxticks=8)) returns'AutodateLocator(maxticks={0: 8, 1: 8, 3: 8, 4: 8, 5: 8, 6: 8, 7: 8})', i.e. the class variablemaxticks. I don't know how to get the value passed in during the function call. But even if this is possible, I find defining all therepr rather verbose and a bit hacky as compared to a simpleeval.

@dstansby
Copy link
Member

In an ideal world we would define sensible__repr__s on each of the locators/formatters so they could be used - I think that's a stretch goal, and this PR is worth considering regardless of that.

story645 reacted with thumbs up emoji

@jklymakjklymak merged commitfb5b91e intomatplotlib:mainDec 7, 2021
@jklymak
Copy link
Member

Thanks@StefRe for your very helpful contributions!

@StefReStefRe deleted the date_fmt-loc_reference branchDecember 8, 2021 07:17
@StefRe
Copy link
ContributorAuthor

@jklymak Thanks!
What about therrulewrapper issue I mentioned at thevery beginning? Open a new issue for this? Should I (for the time being) remove the reference torrulewrapper as there's no link:
grafik

@jklymak
Copy link
Member

Sure, open an issue. Seems the solution is to add a docstring to rrulewrapper if it is public API...

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

@dstansbydstansbydstansby approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.6.0
Development

Successfully merging this pull request may close these issues.

Create Date Formatter/Locator Reference
4 participants
@StefRe@jklymak@story645@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp