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

Appearance settings

Switch transOffset to offset_transform. #21965

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

Merged
merged 1 commit into from
Jan 8, 2022
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 15, 2021

Note that most APIs previously already accepted offset_transform as
kwarg, due to the presence of the set_offset_transform setter. Prefer
that name (shortening it to offset_trf for local variables).

Backcompat for the old transOffset name is kept in most places by
introducing a property alias.

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • 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).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@anntzer anntzer added this to the v3.6.0 milestone Dec 15, 2021
@anntzer anntzer force-pushed the ot branch 3 times, most recently from dacd3fe to 125b87c Compare December 15, 2021 16:25
Comment on lines 223 to 227
if self._offset_trf is None:
self._offset_trf = transforms.IdentityTransform()
elif (not isinstance(self._offset_trf, transforms.Transform)
and hasattr(self._offset_trf, '_as_mpl_transform')):
self._offset_trf = self._offset_trf._as_mpl_transform(self.axes)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why this sort of thing didn't happen in the setter? Is it some kind of optimization to avoid calling _as_mpl_transform?

If it were in the setter, you wouldn't need offset_trf because they'd all fit in a line even with the full name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You'll have to ask @pelson who added this in #1090. I guess that in theory the pseudo-transform (the object with an _as_mpl_transform method) could be mutable and you may want the later mutations to be reflected at draw time?

Copy link
Member

Choose a reason for hiding this comment

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

I can't remember a strong reason for it (though there might have been one). Perhaps there is some delay in getting an axes on a collection, and you can only guarantee it exists when you get_offset_transform?

Certainly worth exploring though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's defer this to another issue, perhaps?

Copy link
Member

@QuLogic QuLogic Jan 5, 2022

Choose a reason for hiding this comment

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

OK, I was mostly trying to avoid the offset_trf abbreviation entirely, and not go into performance details just now. Mainly, I don't mind the name within a function, but as the private member, I'd prefer it matched the name of the property/argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, I renamed to _offset_transform.

Copy link
Member

Choose a reason for hiding this comment

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

I'd go as far as preferring offset_transform also for local variables (unless you have really bad wrapping issues). trf does not speak to me at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we already use trf for local variables if quite a few other places, and I'd rather try to establish it as a standard abbreviation (transform is quite a mouthful). Or we can try to standardize on trans, if you prefer?

Copy link
Member

Choose a reason for hiding this comment

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

I find trans slightly better than trf. I agree that a standard abbreviation is desireable.

Note that most APIs *previously* already accepted *offset_transform* as
kwarg, due to the presence of the `set_offset_transform` setter.  Prefer
that name (shortening it to `offset_trf` for local variables).

Backcompat for the old `transOffset` name is kept in most places by
introducing a property alias.
Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

So long as you work out the name.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

@anntzer If you want to switch the other places from trf to trans, you can start here with transand do the rest of the renaming in a second commit/PR. If not feel free to self-merge as is.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 8, 2022

Let's get this in as is and poll the devs in #22156 :)

@anntzer anntzer merged commit 5de27aa into matplotlib:main Jan 8, 2022
@anntzer anntzer deleted the ot branch January 8, 2022 15:35
yuzie007 added a commit to yuzie007/mpltern that referenced this pull request Feb 19, 2023
While `offset_transform` is introduced since `matplotlib>=3.6.0`,
(matplotlib/matplotlib#21965), `transOffset` can still be used. Also,
instead of `_internal_update` (matplotlib/matplotlib#22451), `update`
can still be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.