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 BoxStyle._Base.#17737

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
timhoffm merged 2 commits intomatplotlib:masterfromanntzer:unboxstyle
Oct 11, 2020
Merged

Conversation

anntzer
Copy link
Contributor

... by moving the mutation_aspect logic to FancyBboxPatch, so that
boxstyles can be plain classes just implementing__call__ and not
inheriting from anything, which removes the need to inherit from a
private base inuserdemo/custom_boxstyle01.py.

A similar approach could be implemented for FancyArrowStyle._Base and
ConnectionStyle._Base.

Closes#13199 (comment).

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.4.0 milestoneJun 23, 2020

def __call__(self, x0, y0, width, height, mutation_size,
aspect_ratio=1.):
return self(self, x0, y0, width, height, mutation_size, 1)
Copy link
Member

Choose a reason for hiding this comment

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

Won't this fail with the wrong error if__call__ is not overridden, since it no longer takes anaspect_ratio argument?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

yes, but subclasses previously needed to override__call__ to get any meaningful behavior, no? previously not overriding it would result in a NotImplementedError from the base class, now you'd get a TypeError at argument binding time but I think that's close enough?

Copy link
Member

Choose a reason for hiding this comment

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

I thought they had to overridetransmute before?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry, I got it wrong just above. Users had to overridetransmute before, which means that the implementation of _Base.transmute is in facto mostly irrelevant for backcompat purposes. I guess I could even leave it as raising a NotImplementedError? (although I would change the error message, which would be confusing)

Copy link
Member

Choose a reason for hiding this comment

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

OK, but now nothing callstransmute? So how would existing subclassers find out the deprecation?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

hum... I guess that in__call__ I can add a call to_deprecate_method_override(__class__.transmute, ...) (and put back the old version of the code under theif transmute := _deprecate_method_override(...) branch)?

Copy link
Member

Choose a reason for hiding this comment

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

Yea, if that works, sounds good.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

New version in, but the whole thing's a bit tricky...

@anntzeranntzerforce-pushed theunboxstyle branch 3 times, most recently fromb109672 to83f6a53CompareSeptember 17, 2020 09:35

def __call__(self, x0, y0, width, height, mutation_size,
aspect_ratio=1.):
return self(self, x0, y0, width, height, mutation_size, 1)
Copy link
Member

Choose a reason for hiding this comment

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

OK, but now nothing callstransmute? So how would existing subclassers find out the deprecation?

... by moving the mutation_aspect logic to FancyBboxPatch, so thatboxstyles can be plain classes just implementing `__call__` and notinheriting from anything, which removes the need to inherit from aprivate base in `userdemo/custom_boxstyle01.py`.A similar approach could be implemented for FancyArrowStyle._Base andConnectionStyle._Base.
@QuLogic
Copy link
Member

If you revert the changes toexamples/userdemo/custom_boxstyle01.py, it crashes on draw, instead of warning about the deprecation.

@anntzer
Copy link
ContributorAuthor

oops,__call__ = transmute should have beencls.__call__ = transmute; fixed.

@timhoffmtimhoffm merged commit319f35b intomatplotlib:masterOct 11, 2020
@anntzeranntzer deleted the unboxstyle branchOctober 11, 2020 10:53
@greglucas
Copy link
Contributor

@anntzer, I was going through removing 3.4 deprecations and I wasn't entirely clear on what you had planned for the final state here. This looks like it can be removed in main now if you're interested in taking it out though.

@anntzeranntzer mentioned this pull requestJun 10, 2022
6 tasks
@anntzer
Copy link
ContributorAuthor

anntzer commentedJun 10, 2022
edited
Loading

Done at#23237. Let's discuss it there.

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

@QuLogicQuLogicQuLogic approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

Examples that use private APIs
4 participants
@anntzer@QuLogic@greglucas@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp