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

Start work on making colormaps picklable. #11723

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
Jul 21, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jul 21, 2018

PR Summary

See discussion in #11716.
Mostly putting this up as an example of how to exploit functools.partial to keep things picklable.

(pycodestyle doesn't like this but I think this should rather be fixed with an exemption, see also PyCQA/pycodestyle#231.)

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

return f(1 - x)
return freversed
def _reverser(f, x=None):
if x is None:
Copy link
Member

Choose a reason for hiding this comment

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

This could use a short explanation even if it's private. Something like

Return a function f' for a given function f such that f'(x) = f(1-x).

Usage: ``_reverser(f)``. The parameter *x* is only used internally.

Maybe also use _x instead of x.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added docstring; left x as such as that's also how it appears in the signature of the partial object.

@dstansby dstansby added this to the v3.0 milestone Jul 21, 2018
@dstansby dstansby merged commit 3448de3 into matplotlib:master Jul 21, 2018
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

I guess ideally test_pickle should test all this so some one doesn’t have the brilliant idea to refactor all these back into lambdas

@anntzer anntzer deleted the picklablecmaps branch July 21, 2018 21:18
@anntzer anntzer mentioned this pull request Aug 17, 2018
6 tasks
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.