Skip to content

Soft-deprecate transform_point.#14652

Merged
jklymak merged 1 commit intomatplotlib:masterfrom
anntzer:transform_point
Jul 5, 2019
Merged

Soft-deprecate transform_point.#14652
jklymak merged 1 commit intomatplotlib:masterfrom
anntzer:transform_point

Conversation

@anntzer
Copy link
Copy Markdown
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

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

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
Copy Markdown
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
Copy Markdown
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.

4 participants