Skip to content

FIX: remove recursive call to str in transform repr #11189

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 2 commits into from
May 8, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented May 7, 2018

PR Summary

This makes __repr__ for transform objects just a one-line object repr.

It retains the pretty-print for print.

It fixes the recursion in #11163

Supercedes #11173, if we think that __repr__ should return something short.... If we think __repr__ should be more verbose, this is the wrong solution, and #11173 is correct.

Closes #11163.

In [1]: from matplotlib import pyplot as plt
   ...: import numpy as np
   ...:
   ...: f, ax = plt.subplots()
   ...: ax.plot(np.arange(100))
   ...: ax.set_yscale('symlog')
   ...: ax.get_yaxis_transform()
   ...:
Out[1]: <matplotlib.transforms.BlendedGenericTransform at 0x10fcff908>

In [2]: print(ax.get_yaxis_transform())
BlendedGenericTransform(
    BboxTransformTo(
        TransformedBbox(
            Bbox(x0=0.125, y0=0.10999999999999999, x1=0.9, y1=0.88),
            BboxTransformTo(
                TransformedBbox(
                    Bbox(x0=0.0, y0=0.0, x1=6.4, y1=4.8),
                    Affine2D(
                        [[ 200.    0.    0.]
                         [   0.  200.    0.]
                         [   0.    0.    1.]]))))),
    CompositeGenericTransform(
        TransformWrapper(
            BlendedGenericTransform(
                IdentityTransform(),
                <matplotlib.scale.SymmetricalLogTransform object at 0x1179b4f28>)),
        CompositeGenericTransform(
            BboxTransformFrom(
                TransformedBbox(
                    Bbox(x0=-4.95, y0=-0.2525144679040212, x1=103.95, y1=136.74800843761523),
                    TransformWrapper(
                        BlendedGenericTransform(
                            IdentityTransform(),
                            <matplotlib.scale.SymmetricalLogTransform object at 0x1179b4f28>)))),
            BboxTransformTo(
                TransformedBbox(
                    Bbox(x0=0.125, y0=0.10999999999999999, x1=0.9, y1=0.88),
                    BboxTransformTo(
                        TransformedBbox(
                            Bbox(x0=0.0, y0=0.0, x1=6.4, y1=4.8),
                            Affine2D(
                                [[ 200.    0.    0.]
                                 [   0.  200.    0.]
                                 [   0.    0.    1.]]))))))))

PR Checklist

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

@jklymak
Copy link
Member Author

jklymak commented May 7, 2018

OK, the other time we didn't fix the root cause of this (#10242) had a comparison of the repr. I've removed that because it obviously fails now.

@efiring efiring merged commit 71b181f into matplotlib:master May 8, 2018
@efiring
Copy link
Member

efiring commented May 8, 2018

Does this need to be backported?

@anntzer
Copy link
Contributor

anntzer commented May 8, 2018

Would probably be a good idea.

@jklymak jklymak deleted the fix-repr-recursion branch May 16, 2018 16:38
@jklymak jklymak restored the fix-repr-recursion branch May 16, 2018 16:39
@jklymak
Copy link
Member Author

jklymak commented May 16, 2018

@meeseeksdev backport to v2.2.x

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.

RecursionError when calling get_yaxis_transform() on a Symlog-scaled axis.
5 participants