FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Restore axes sharedness when unpickling. by anntzer · Pull Request #11544 · matplotlib/matplotlib · GitHub

Repository navigation

Restore axes sharedness when unpickling. - #11544

Merged
jklymak merged 1 commit into
matplotlib:masterfrom
anntzer:pickleshared2
Jul 4, 2018
Merged

jklymak merged 1 commit into
matplotlib:masterfrom
anntzer:pickleshared2

Conversation

anntzer commented Jul 1, 2018

Copy link
Copy Markdown
Contributor

Alternative implementation of #10659, which addresses the issues raised in the comments.

Previously, pickling and unpickling shared axes would result in
axes sharing a ticker instance (because that's how shared axes
are set up), but without changes of one's xlims propagated to the
other. The reason is that that sharedness information is stored in
AxesBase._shared_x_axes, which does not get pickled together with the
Axes instance: the latter only has a textual reference "I am an instance
of AxesBase", so the Grouper information is lost.

this is the part of the implementation that changed

To keep the Grouper information valid, additionally pickle the current
group of shared axes together with the Axes, and restore that
information upon unpickling.

end of diff

PR Summary

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

Previously, pickling and unpickling shared axes would result in
axes sharing a ticker instance (because that's how shared axes
are set up), but without changes of one's xlims propagated to the
other.  The reason is that that sharedness information is stored in
AxesBase._shared_x_axes, which does *not* get pickled together with the
Axes instance: the latter only has a textual reference "I am an instance
of AxesBase", so the Grouper information is lost.

To keep the Grouper information valid, additionally pickle the current
group of shared axes together with the Axes, and restore that
information upon unpickling.
anntzer added this to the v3.0 milestone Jul 1, 2018

timhoffm commented Jul 1, 2018

Copy link
Copy Markdown
Member

So, is it correct that now

  1. Pickling and unpickling two shared axes shared axes is now fully transparent?

  2. Having two shared axes A, B and just pickling and unpickling B in the same session breaks the relation because B will have a new grouper?

Would be good enough for me. Do we have some place to document that you would always have to pickle the full set of shared axes together?

anntzer commented Jul 1, 2018

Copy link
Copy Markdown
Contributor Author

Pickling and unpickling two shared axes shared axes is now fully transparent?

To the best of my knowledge...

Having two shared axes A, B and just pickling and unpickling B in the same session breaks the relation because B will have a new grouper?

No, because there is a single grouper instance, unpickling B just readds its connected component to it (which is already there and doesn't change anything). Manually trying that (e.g. pickle.loads(pickle.dumps(ax_b))) works, too.

jklymak left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this is right...

jklymak merged commit d9d7ff1 into matplotlib:master Jul 4, 2018
anntzer deleted the pickleshared2 branch July 4, 2018 18:12

Copy link
Copy Markdown
Member

I am glad this ended up being much simpler than I expected.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL