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

Commit 3448de3

Browse filesBrowse files
authored
Merge pull request #11723 from anntzer/picklablecmaps
Start work on making colormaps picklable.
2 parents 66a6d70 + 564e478 commit 3448de3
Copy full SHA for 3448de3

File tree

Expand file treeCollapse file tree

3 files changed

+19
-15
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+19
-15
lines changed

‎.flake8

Copy file name to clipboardExpand all lines: .flake8
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ per-file-ignores =
2828
tools/compare_backend_driver_results.py: E501
2929
tools/subset.py: E221, E231, E251, E261, E302, E501, E701
3030

31-
matplotlib/_cm.py: E202, E203
31+
matplotlib/_cm.py: E202, E203, E302
3232
matplotlib/_mathtext_data.py: E203, E261
3333
matplotlib/backend_bases.py: E225
3434
matplotlib/backends/_backend_tk.py: E203, E222, E225, E231, E271, E301, E303, E401, E501, E701

‎lib/matplotlib/_cm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_cm.py
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
'blue': ((0., 0., 0.),
4242
(1.0, 0.4975, 0.4975))}
4343

44-
_flag_data = {
45-
'red': lambda x: 0.75 * np.sin((x * 31.5 + 0.25) * np.pi) + 0.5,
46-
'green': lambda x: np.sin(x * 31.5 * np.pi),
47-
'blue': lambda x: 0.75 * np.sin((x * 31.5 - 0.25) * np.pi) + 0.5,
48-
}
4944

50-
_prism_data = {
51-
'red': lambda x: 0.75 * np.sin((x * 20.9 + 0.25) * np.pi) + 0.67,
52-
'green': lambda x: 0.75 * np.sin((x * 20.9 - 0.25) * np.pi) + 0.33,
53-
'blue': lambda x: -1.1 * np.sin((x * 20.9) * np.pi),
54-
}
45+
def _flag_red(x): return 0.75 * np.sin((x * 31.5 + 0.25) * np.pi) + 0.5
46+
def _flag_green(x): return np.sin(x * 31.5 * np.pi)
47+
def _flag_blue(x): return 0.75 * np.sin((x * 31.5 - 0.25) * np.pi) + 0.5
48+
def _prism_red(x): return 0.75 * np.sin((x * 20.9 + 0.25) * np.pi) + 0.67
49+
def _prism_green(x): return 0.75 * np.sin((x * 20.9 - 0.25) * np.pi) + 0.33
50+
def _prism_blue(x): return -1.1 * np.sin((x * 20.9) * np.pi)
51+
52+
53+
_flag_data = {'red': _flag_red, 'green': _flag_green, 'blue': _flag_blue}
54+
_prism_data = {'red': _prism_red, 'green': _prism_green, 'blue': _prism_blue}
5555

5656

5757
def cubehelix(gamma=1.0, s=0.5, r=-1.5, h=1.0):

‎lib/matplotlib/cm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cm.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
See :doc:`/tutorials/colors/colormaps` for an in-depth discussion of colormaps.
66
"""
77

8+
import functools
9+
810
import numpy as np
911
from numpy import ma
1012

@@ -22,10 +24,12 @@
2224
# reversed colormaps have '_r' appended to the name.
2325

2426

25-
def _reverser(f):
26-
def freversed(x):
27-
return f(1 - x)
28-
return freversed
27+
def _reverser(f, x=None):
28+
"""Helper such that ``_reverser(f)(x) == f(1 - x)``."""
29+
if x is None:
30+
# Returning a partial object keeps it picklable.
31+
return functools.partial(_reverser, f)
32+
return f(1 - x)
2933

3034

3135
def revcmap(data):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.