Skip to content

Add improved modification of QuiverKey properties #18794

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Oct 23, 2020

PR Summary

QuiverKey previously had several attributes that were saved from the constructor, but these were never linked to the internal Artists that were actually drawn.

This adds getters and setters for said properties, and instead of a separate copy of the information, just grabs/sets it on the internal Text child. Additionally, it deprecates access to these internal children; other than .text, they were always overwritten in draw, so there was no way to make real use of them.

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@QuLogic QuLogic added this to the v3.4.0 milestone Oct 23, 2020
@QuLogic QuLogic modified the milestones: v3.4.0, v3.5.0 Feb 10, 2021
self._initialized = False
self.zorder = Q.zorder + 0.1

def get_x(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can do without {get,set}_{x,y} and just stick to get_position (as for Text)? the backcompat X and Y would be kept for backcompat but can use straight lambdas (X = property(lambda self: self._text.get_position()[0], self.text.set_x) -- setting stale shouldn't really matter here as Text will propagate staleness to the parent Axes anyways)

Copy link
Member

Choose a reason for hiding this comment

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

Agree. We only have get_x on Rectangle and FancyBboxPatch. Let's keep the API size down and only provide get/set_position.

self._update_text_transform()
self.stale = True

@property
Copy link
Contributor

Choose a reason for hiding this comment

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

consider deprecating this, given the potential source of confusion?

Copy link
Member

Choose a reason for hiding this comment

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

Agree.


- ``QuiverKey.text``
- ``QuiverKey.vector``
- ``QuiverKey.verts``
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps someone may want e.g. to set usetex or math_fontfamily or whatnot on the Text; do you really want to deprecate access to it?

Copy link
Member

Choose a reason for hiding this comment

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

Keeping text public is the pragmatic thing to do.

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

None of the suggestions above are blocking, but please consider them.

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

@QuLogic feel free to self-merge if you don't want to address the comments @anntzer left - we can have follow up PRs if helpful.

@jklymak jklymak added the status: needs clarification Issues that need more information to resolve. label May 21, 2021
@jklymak jklymak marked this pull request as draft May 21, 2021 19:39
@QuLogic QuLogic modified the milestones: v3.5.0, v3.6.0 Aug 23, 2021
@timhoffm timhoffm modified the milestones: v3.6.0, unassigned Apr 30, 2022
@story645 story645 modified the milestones: unassigned, needs sorting Oct 6, 2022
@github-actions
Copy link

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Aug 30, 2023
QuLogic added 3 commits March 26, 2024 06:57
Additionally, add getters/setters for these properties, and use an
`offset_copy` Transform to implement `labelsep`. This makes one less
thing depending on the DPI change signal.
@QuLogic
Copy link
Member Author

QuLogic commented Mar 27, 2024

I finally got around to rebasing this, though I don't really remember why I started this PR in the first place.

@timhoffm what do you think about the API changes here, mainly the comments from @anntzer? I also had to use [gs]et_label_text instead of [gs]et_label because of conflicting types with Artist, but I realize now that's just from the automatic object->str cast, and maybe I could allow that in order to go back to the generic name.

@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label Mar 28, 2024
@timhoffm
Copy link
Member

Commented on @anntzer‘s suggestions.

label: Unfortunately, Artist.set_label is tied to the specific meaning: The label an artist gets in a legend. I‘m against repurposing that function for another usecase. See also #27971 (comment).

Can‘t we leave the text instance public? As far as I’ve understood from your initial comment, that should be technically possible. It’s not too pretty, but saves the forwarding functions as well as preventing the label naming issues. I‘d say that’s the pragmatic approach: Supporting full access for the rare cases a user needs it, but not generating much overhead on our side.

@QuLogic
Copy link
Member Author

QuLogic commented Mar 28, 2024

Can‘t we leave the text instance public? As far as I’ve understood from your initial comment, that should be technically possible. It’s not too pretty, but saves the forwarding functions as well as preventing the label naming issues. I‘d say that’s the pragmatic approach: Supporting full access for the rare cases a user needs it, but not generating much overhead on our side.

Yes, that does seem possible; should we deprecate the QuiverKey.label* attributes that previously would not do anything if changed, or keep the (new in this PR) properties?

@timhoffm
Copy link
Member

Let's deprecate all the label* attributes direct people to working with the QuiverKey.text instance. That's good enough. QuiverKey in itself is not one of the most used parts of the library, and modifying an existing QuiverKey even less so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature status: needs clarification Issues that need more information to resolve. status: needs rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants