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

Rename parameter selectors#20585

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

ericpre
Copy link
Member

@ericpreericpre commentedJul 6, 2021
edited
Loading

PR Summary

Follow up of#20558. Rename parameters (maxdist,markers_props, etc.) to make them consistent between the different selectors.

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • [n/a] New features are documented, with examples if plot related.
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • [n/a] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@tacaswelltacaswell added this to thev3.5.0 milestoneJul 6, 2021
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.

Seems reasonable, left 2 small comments.

@ericpre
Copy link
MemberAuthor

Thanks for the review@tacaswell, it should be good now.

@ericpre
Copy link
MemberAuthor

Should be all done!

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

I know that some of the commented changes have precedence in other widget classes, however I'm not convinced, we should go that direction (e.g. code blocks for defaults).


dict(color='k', linestyle='-', linewidth=2, alpha=0.5)

handle_props : dict
Copy link
Member

Choose a reason for hiding this comment

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

Let's the namemarkerprops. This is a bit different fromSpanSelector. First, here we havelineprops +markerprops, keeping this consistent within the class is more important than consistency with another class. Second, while semantically we have handles in both classes, they are realized by markers and lines respectively and thus accept different parameters. I favor making this clear from the name.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I see what you what you mean, but I am convinced that simplifying the API and making it more generic is worth it at the cost of the being slightly less precise. I agree that using a more specific terminology is more explicit but at the end of the day, when we create a selector - regardless of what selector it is - what we want is to set the properties of the patch and/or the handle, regardless of what their are or of their implementation details.
For example, as an average matplotlib user, I don't know what are the different parameters betweenlineprops andmarkerprops, I will need to look it up.

In35ee92d, I have changed the various patch properties (rectprops,lineprops) argument toprops, so that now we have onlyprops andhandleprops for all selectors.
To address#20618, we could add two method to set the properties of the selector patch and the handle separately. The idea is that either at initialisation or when usingset_props orset_handle_props, we could set the properties regardless of what type of object they are.

I am happy to revert35ee92d if others also think that this is going in the wrong direction!

Copy link
Member

Choose a reason for hiding this comment

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

For example, as an average matplotlib user, I don't know what are the different parameters betweenlineprops andmarkerprops, I will need to look it up.

Conversely, I argue thatprops is even less helpful. The different selectors are realized by different Artists and thus have different properties. We cannot hide that fact.SpanSelector acceptsfacecolor,LassoSelector acceptssolid_linestyle, and neither accepts the other one respectively. Withprops the user has to lookup what is supported as well. But it's more surpising and harder to remember that the same parameter name accepts different inputs depending on the class.

state_modifier_keys : dict, optional
Keyboard modifiers which affect the widget's behavior. Values
amend the defaults.
@docstring.Substitution(_RECTANGLESELECTOR_PARAMETERS_DOCSTRING)
Copy link
Member

Choose a reason for hiding this comment

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

Why this indirection?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

To be able to reuse the docstring in EllipseSelector and RectangleSelector.

Copy link
Member

@timhoffmtimhoffmJul 11, 2021
edited
Loading

Choose a reason for hiding this comment

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

I see. I'm not a fan of too much indirection in the docs. Some duplication is ok sometimes.

Reuse implies coupling. The risk with indirection is that people start to write about Rectangle explicitly, which does not make sense for the Ellipse case. Conversly, the risk with duplicated docstrings is that they are not in sync (which IMHO is not the end of the world).
I even claim it's a mistake thatEllipseSelector inherits fromRectangleSelector.

It's a tradeoff which I would decide in favor of the duplication here. But I'm not going to fight over it.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I have put a placeholder for the artist type to be replaced byellipse orselector to fix this issue.

I even claim it's a mistake thatEllipseSelector inherits fromRectangleSelector.

I don't know about that, maybe for another PR! ;)

@timhoffm
Copy link
Member

Ok, so here is an overview of the current APIs

grafik

  • Green entries are consistent (don't need any change).
  • Orange entries should be synchronized.
  • Yellow: needs discussion.

props andhandle_props face the same problem that the selection indicator and the handles respectively are realized by different objects in the different classes and thus accept different values depending on the class. An additional complication is thatRectangleSelector /EllipseSelector takeslineprops orrectprops depending ondrawtype. Either solution for that is bad (drawtype deciding which parameters are accepted anddrawtype deciding which values of aprop parameter are supported).

Given the overall situation I propose the following:

  • lineprops/rectprops get unified toprops, but each docstring has to clearly specify which values are supported by linking the respective Artist properties.
  • Similarly, we unifiy tohandle_props and also link the Artist properties.
  • We unify tohandle_grab_distance /vertex_select_radius /maxdist tograb_range (or if you wanthandle_grab_range).

@ericpre
Copy link
MemberAuthor

ericpre commentedJul 12, 2021
edited
Loading

Thanks@timhoffm for the summary, this clarify the current situation!
I have improve the docstrings in44b37fb, where I have tried to put the relevant links to the doc and I have renamehandle_grab_distance tograb_range ina22f8cb.

@ericpreericpreforce-pushed therename_parameter_selectors branch from97456b4 toa22f8cbCompareJuly 12, 2021 15:55
@QuLogic
Copy link
Member

An additional complication is thatRectangleSelector /EllipseSelector takeslineprops orrectprops depending ondrawtype. Either solution for that is bad (drawtype deciding which parameters are accepted anddrawtype deciding which values of aprop parameter are supported).

We should not worry aboutdrawtype in designing the desired configuration API, because it's deprecated already.

@timhoffm
Copy link
Member

timhoffm commentedJul 13, 2021
edited
Loading

We should not worry aboutdrawtype in designing the desired configuration API, because it's deprecated already.

Thanks for pointing this out, I have overlooked this. However, I don't think it changes the above assessment. We're still atrect_props forRectangleSelector andEllipseSelector. The name is awkward for the latter. Though, I would also be ok to leave onelineprops /rectprops parameter per Selector for now.

@ericpre
Copy link
MemberAuthor

I think that I have addressed all comments. I have no idea why the doc build is failing and I can't see how it is related to this PR; the warning is:

/home/circleci/project/lib/matplotlib/projections/geo.py:docstring of matplotlib.projections.geo.GeoAxes.set_xlim:47: WARNING: py:obj reference target not found: get_ylim

@QuLogic
Copy link
Member

A rebase should fix that.

@ericpreericpreforce-pushed therename_parameter_selectors branch fromf8df989 to8ff493cCompareJuly 16, 2021 20:22
@ericpre
Copy link
MemberAuthor

A rebase should fix that.

Ok, thanks!

ericpreand others added2 commitsJuly 17, 2021 09:01
… deprecationCo-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@ericpre
Copy link
MemberAuthor

Thanks@timhoffm, I have updated the span selector example too.

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

Thanks for the quick response. I did a careful full review now, which revealed still some open issues.

@ericpreericpreforce-pushed therename_parameter_selectors branch fromb3925a9 to8682b5fCompareJuly 19, 2021 08:46
@timhoffmtimhoffm merged commit9869421 intomatplotlib:masterJul 19, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@QuLogicQuLogicQuLogic left review comments

@anntzeranntzeranntzer left review comments

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

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

Successfully merging this pull request may close these issues.

6 participants
@ericpre@timhoffm@QuLogic@tacaswell@anntzer@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp