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

Deprecate position argument to Axes.apply_aspect()#23629

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

Closed

Conversation

timhoffm
Copy link
Member

PR Summary

In itselfapply_aspect() feels too low level to be needed by an end-user. I'm not sure if it reasonably works at all on its own. It might be that the result is influenced by other artists and if something is left stale, then the application result is still not final. In that case, one would need a full draw (without rendering) anyway. OTOH ifapply_aspect() was really standalone, I don't know why we defer the application and don't apply it immediately when setting the aspect.

Also, theposition parameter ofapply_aspect does not seem a user-facing API. It is used internally by layout mechanisms. But shifting the position explicitly as part of aspect application seems overreach of the scope of the function and at least not something a user should do.

I'm 99% percent sureapply_aspect() does not need to be public API, but please speak up if you think otherwise. And even if we miss a justified use-case for a user. They should be able to give feedback during the deprecation period and we would reconsider then.

@tacaswelltacaswell added this to thev3.6.0 milestoneAug 15, 2022
@jklymak
Copy link
Member

I think if you search on stackoverflow there are quite a few answers that suggest calling apply_aspect to get the position of things after the proper aspect ratio is applied without forcing a full draw.

@jklymak
Copy link
Member

@timhoffm
Copy link
MemberAuthor

timhoffm commentedAug 18, 2022
edited
Loading

Well, maybe only a couple:https://stackoverflow.com/search?q=%5Bmatplotlib%5D+apply_aspect

From these:

    1. and 5) only showapply_aspect in unrelated parts of a traceback.
  • 1), 2), 4) use it for a layout update because they want to query Axes sizes. - Note also that in 1@tacaswell suggests "I strongly suspect that you just need to call draw after calling set_aspect."

Anyway, let's be super-safe and only deprecate the publicposition parameter for now. - No end user should manipulate the position throughapply_aspect(). And I haven't seen anything in the wild.

@QuLogicQuLogic changed the titleDeprecate Axes.apply_aspect()Deprecate position argument to Axes.apply_aspect()Aug 18, 2022
@QuLogic
Copy link
Member

Please update the commit message as well for that.

timhoffm reacted with thumbs up emoji

@timhoffmtimhoffmforce-pushed thedeprecate-apply-aspect branch 2 times, most recently from7784ff2 to38fbaadCompareAugust 19, 2022 00:05
Copy link
Member

@QuLogicQuLogic left a comment

Choose a reason for hiding this comment

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

I've found a use ofapply_aspect in the wild that this rename would likely break without the deprecation triggering
https://github.com/AudioSceneDescriptionFormat/splines/blob/master/doc/rotation/helper.py#L275

I'm not entirely sure what they are attempting to do there.

@@ -0,0 +1,3 @@
The parameter *position* in ``Axes.apply_aspect()``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... is deprecated. It is considered internal API and now public use case is known.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
... is deprecated. It is considered internal API andnow public use case is known.
... is deprecated. It is considered internal API andno public use case is known.

Comment on lines 1869 to 1885
position : None or .Bbox

If not ``None``, this defines the position of the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
position :Noneor .Bbox
Ifnot``None``,thisdefinesthepositionofthe
position :Noneor .Bbox
Ifnot``None``,thisdefinesthepositionofthe

@QuLogic
Copy link
Member

@timhoffmtimhoffm modified the milestones:v3.6.0,v3.7.0Aug 19, 2022
@timhoffm
Copy link
MemberAuthor

timhoffm commentedAug 19, 2022
edited
Loading

Deferred to 3.7. Let’s not rush this into 3.6.

This needs a more thorough investigation.

@timhoffmtimhoffm marked this pull request as draftAugust 19, 2022 07:50
@timhoffm
Copy link
MemberAuthor

Digging through the history my understanding of the reason for the position parameter is the following:

It is somewhat surprising that "_apply_aspect" takes an optional position as input, which seems more functionality than what the name suggests.

The parameter was introduced in66290aae. Generally, applying an aspect will modify the size and position of an Axes. The fact that position is updated anyway was used to funnel additional position information from a layoutinto the already existing positioning code.

IMHO:

  • Theposition parameter should never be used by an end-user.
  • The function_apply_aspect should rather be calledupdate_geometry or similar.

I see two ways forward:

  1. Simply document thatposition is not meant to be user-facing. And don't bother further with the topic.
  2. Go further with a formal deprecation, which means we need a publicapply_aspect() that will become parameter-less. And we need a new private API to carry the position. This has compatibility implications for 3rd party Axes subclasses (see@QuLogic's links above).

I'm inclined to go with 1.


One use of apply_aspect that maybe could be a draw:https://github.com/hannorein/rebound/blob/main/rebound/plotting.py#L103-L107

has meanwhile been changed to a draw. 👍

timhoffm added a commit to timhoffm/matplotlib that referenced this pull requestJun 4, 2024
Superseedsmatplotlib#23629.It is somewhat surprising that "_apply_aspect" takes anoptional position as input, which seems more functionalitythan what the name suggests.The parameter was introduced in66290aa. Generally, applyingan aspect will modify the size and position of an Axes. Thefact that position is updated anyway was used to funneladditional position information from a layout into the alreadyexisting positioning code.Deprecating and removing the parameter would be a medium compatibilityhassle. Therefore, I chose only to document the status quo and itsintention, so that users are less surprised. Seematplotlib#23629 (comment)
timhoffm added a commit to timhoffm/matplotlib that referenced this pull requestJun 4, 2024
Superseedsmatplotlib#23629.It is somewhat surprising that "_apply_aspect" takes anoptional position as input, which seems more functionalitythan what the name suggests.The parameter was introduced in66290aa. Generally, applyingan aspect will modify the size and position of an Axes. Thefact that position is updated anyway was used to funneladditional position information from a layout into the alreadyexisting positioning code.Deprecating and removing the parameter would be a medium compatibilityhassle. Therefore, I chose only to document the status quo and itsintention, so that users are less surprised. Seematplotlib#23629 (comment)
timhoffm added a commit to timhoffm/matplotlib that referenced this pull requestJun 4, 2024
Superseedsmatplotlib#23629.It is somewhat surprising that "_apply_aspect" takes anoptional position as input, which seems more functionalitythan what the name suggests.The parameter was introduced in66290aa. Generally, applyingan aspect will modify the size and position of an Axes. Thefact that position is updated anyway was used to funneladditional position information from a layout into the alreadyexisting positioning code.Deprecating and removing the parameter would be a medium compatibilityhassle. Therefore, I chose only to document the status quo and itsintention, so that users are less surprised. Seematplotlib#23629 (comment)
timhoffm added a commit to timhoffm/matplotlib that referenced this pull requestJun 4, 2024
Superseedsmatplotlib#23629.It is somewhat surprising that "_apply_aspect" takes anoptional position as input, which seems more functionalitythan what the name suggests.The parameter was introduced in66290aa. Generally, applyingan aspect will modify the size and position of an Axes. Thefact that position is updated anyway was used to funneladditional position information from a layout into the alreadyexisting positioning code.Deprecating and removing the parameter would be a medium compatibilityhassle. Therefore, I chose only to document the status quo and itsintention, so that users are less surprised. Seematplotlib#23629 (comment)
@timhoffm
Copy link
MemberAuthor

Not going forward with the deprecation. The parameter is now documented as internal and that's good enough.

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

@QuLogicQuLogicQuLogic left review comments

@tacaswelltacaswelltacaswell approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
future releases
Development

Successfully merging this pull request may close these issues.

4 participants
@timhoffm@jklymak@QuLogic@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp