Skip to content
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

Soft-deprecate transform_point. #14652

Merged
merged 1 commit into from Jul 5, 2019
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 29, 2019

The transform() method has explicit code to handle 1d input, so
transform_point() is redundant with transform() (... and is anyways
implemented in terms of transform(), so not faster either)... and longer
to type.

Replace it throughout the codebase. Also compress consecutive calls
to transform_point() with a single call to transform(), which may be a
bit faster (one matrix multiplication instead of two); also a single
replacement to use transform_bbox as appropriate.

Only "deprecate" transform_point in the docs because I don't really want
to discuss here whether this would be too disruptive...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

@@ -738,8 +738,8 @@ class Axis(martist.Artist):
OFFSETTEXTPAD = 3

def __str__(self):
return self.__class__.__name__ \
+ "(%f,%f)" % tuple(self.axes.transAxes.transform_point((0, 0)))
return "{} ({},{})".format(
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
return "{} ({},{})".format(
return "{}({}, {})".format(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed

@@ -174,8 +174,8 @@ def _set_lim_and_transforms(self):

def _get_affine_transform(self):
transform = self._get_core_transform(1)
xscale, _ = transform.transform_point((np.pi, 0))
_, yscale = transform.transform_point((0, np.pi / 2.0))
(xscale, _), (_, yscale) = transform.transform(
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this change is worth it. Probably slightly faster but less readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unchanged

The transform() method has explicit code to handle 1d input, so
transform_point() is redundant with transform() (... and is anyways
implemented in terms of transform(), so not faster either)... and longer
to type.

Replace it throughout the codebase.  Also compress consecutive calls
to transform_point() with a single call to transform(), which may be a
bit faster (one matrix multiplication instead of two); also a single
replacement to use transform_bbox as appropriate.

Only "deprecate" transform_point in the docs because I don't really want
to discuss here whether this would be too disruptive...
@jklymak jklymak merged commit ace52ff into matplotlib:master Jul 5, 2019
@anntzer anntzer deleted the transform_point branch July 5, 2019 15:20
@QuLogic QuLogic added this to the v3.2.0 milestone Jul 17, 2019
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.

None yet

4 participants