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

Shorten implementation of Axes methods that just wrap Axis methods.#16903

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

Conversation

anntzer
Copy link
Contributor

... by autogenerating wrappers that forward to the Axis methods.

Admittedly docstring search/replace is a bit ugly, but this has to be
compared with having 4 copies of the docstrings for each method (Axis,
xaxis, yaxis, zaxis) each to be kept in sync.

(As an anecdote, the ability to do this templatization for mplot3d was what originally motivated me to check whether minor ticks could easily be fixed for 3d axes...)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 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

@anntzeranntzer added this to thev3.3.0 milestoneMar 25, 2020
@anntzeranntzerforce-pushed thetemplatize-axiswrappers branch 3 times, most recently fromde876cc to61c99b6CompareApril 4, 2020 12:05
Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

I like this. It also helps make sure that pass-throughs remain pass-throughs

Makes the judgement in#17028 to do it on the Axis even more persuasive.

@anntzer
Copy link
ContributorAuthor

I pushed a slightly different implementation (directly lifting the "Placeholder" class out) and left some comments explaining why this relies on__set_name__ and how it works.

to the ``get_bar`` method of the ``xaxis`` attribute, and gets its
signature and docstring from ``Axis.get_bar``.

The docstring of ``get_foo`` is built by replacing "this Axis" by "the
Copy link
Member

Choose a reason for hiding this comment

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

I'm slightly worried that subsequent edits on the docstring will break this clever replacements. People usually won't know that "this Axis" has a special meaning. They could easily write:

  • this axis
  • this `.Axis`
  • the axis

I'm afraid that we can't do much in terms of documenting this for docstring authors or warning upon processing. But let's at least include the first two variants for replacement.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I'd rather keep things consistent. Note that there is an assertion check that the correct substring is present, with a hopefully clear error message -- and the check occurs at import time, so we'd easily catch it in CI.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I did not realize the assert.

@anntzeranntzerforce-pushed thetemplatize-axiswrappers branch from98534b6 toaab2b3fCompareApril 5, 2020 18:03
to the ``get_bar`` method of the ``xaxis`` attribute, and gets its
signature and docstring from ``Axis.get_bar``.

The docstring of ``get_foo`` is built by replacing "this Axis" by "the
Copy link
Member

Choose a reason for hiding this comment

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

Ok, I did not realize the assert.

@timhoffm
Copy link
Member

timhoffm commentedApr 5, 2020
edited
Loading

Lot's of warnings in the sphinx build

/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.BarAB:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Bracket/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.BracketA:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Bracket/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.BracketAB:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Bracket/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.BracketB:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Bracket/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.Curve:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Curve/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.CurveA:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Curve/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.CurveAB:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Curve/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.CurveB:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Curve/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.CurveFilledA:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Curve/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.CurveFilledAB:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Curve/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.CurveFilledB:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Curve/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.Fancy:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.Simple:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ArrowStyle.Wedge:1: WARNING: py:class reference target not found: matplotlib.patches.ArrowStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.BoxStyle.Circle:1: WARNING: py:class reference target not found: matplotlib.patches.BoxStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.BoxStyle.DArrow:1: WARNING: py:class reference target not found: matplotlib.patches.BoxStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.BoxStyle.LArrow:1: WARNING: py:class reference target not found: matplotlib.patches.BoxStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.BoxStyle.Round:1: WARNING: py:class reference target not found: matplotlib.patches.BoxStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.BoxStyle.Round4:1: WARNING: py:class reference target not found: matplotlib.patches.BoxStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.BoxStyle.Sawtooth:1: WARNING: py:class reference target not found: matplotlib.patches.BoxStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.BoxStyle.Square:1: WARNING: py:class reference target not found: matplotlib.patches.BoxStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ConnectionStyle.Angle:1: WARNING: py:class reference target not found: matplotlib.patches.ConnectionStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ConnectionStyle.Angle3:1: WARNING: py:class reference target not found: matplotlib.patches.ConnectionStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ConnectionStyle.Arc:1: WARNING: py:class reference target not found: matplotlib.patches.ConnectionStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ConnectionStyle.Arc3:1: WARNING: py:class reference target not found: matplotlib.patches.ConnectionStyle._Base/home/circleci/project/lib/matplotlib/patches.py:docstring of matplotlib.patches.ConnectionStyle.Bar:1: WARNING: py:class reference target not found: matplotlib.patches.ConnectionStyle._Base/home/circleci/project/lib/mpl_toolkits/axisartist/axisline_style.py:docstring of mpl_toolkits.axisartist.axisline_style.AxislineStyle.SimpleArrow:1: WARNING: py:class reference target not found: mpl_toolkits.axisartist.axisline_style.AxislineStyle._Base/home/circleci/project/lib/mpl_toolkits/axisartist/axislines.py:docstring of mpl_toolkits.axisartist.axislines.AxisArtistHelper.Fixed:1: WARNING: py:class reference target not found: mpl_toolkits.axisartist.axislines.AxisArtistHelper._Base/home/circleci/project/lib/mpl_toolkits/axisartist/axislines.py:docstring of mpl_toolkits.axisartist.axislines.AxisArtistHelper.Floating:1: WARNING: py:class reference target not found: mpl_toolkits.axisartist.axislines.AxisArtistHelper._Base

I think they are unrelated, but not sure about it.

Edit: Same warnings in#17021. Either we have commited something that breaks these or it's caused by sphinx 3.0.0, which has been released a couple of hours ago.

@anntzer
Copy link
ContributorAuthor

anntzer commentedApr 5, 2020
edited
Loading

I'd believe it's something to do with sphinx 3.0, but I'm fine waiting for that to be handled first (e.g. by temporarily pinning to <3.0) before merging this.

Edit: rebased over the sphinx fix.

... by autogenerating wrappers that forward to the Axis methods.Admittedly docstring search/replace is a bit ugly, but this has to becompared with having 4 copies of the docstrings for each method (Axis,xaxis, yaxis, zaxis) each to be kept in sync.
@anntzeranntzerforce-pushed thetemplatize-axiswrappers branch fromaab2b3f to1f62d29CompareApril 6, 2020 15:14
@timhoffmtimhoffm merged commit348e9fe intomatplotlib:masterApr 6, 2020
@anntzeranntzer deleted the templatize-axiswrappers branchApril 6, 2020 17:28
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

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

Successfully merging this pull request may close these issues.

3 participants
@anntzer@timhoffm@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp