Skip to content

Commit 931e42b

Browse files
committed
Move colormap check
1 parent 44cc8e8 commit 931e42b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lightning/types/plots.py

-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ def clean(matrix, colormap=None):
9393
matrix = mat_to_array(matrix)
9494
outdict = {'matrix': matrix}
9595

96-
if colormap:
97-
check_colormap(colormap)
98-
9996
outdict = add_property(outdict, colormap, 'colormap')
10097

10198
return outdict

lightning/types/utils.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def check_property(prop, name, **kwargs):
2424
'size': check_size,
2525
'index': check_index,
2626
'coordinates': check_coordinates,
27+
'colormap': check_colormap
2728
}
2829

2930
if name in checkers:
@@ -70,12 +71,14 @@ def check_colormap(cmap):
7071
"""
7172
Check if cmap is one of the colorbrewer maps
7273
"""
73-
names = set(['BrBG', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'Blues', 'BuGn', 'BuPu',
74-
'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds',
75-
'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'Accent', 'Dark2',
76-
'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3'])
74+
names = set(['BrBG', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral',
75+
'Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu',
76+
'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd',
77+
'Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3', 'Lightning'])
7778
if cmap not in names:
7879
raise Exception("Invalid cmap '%s', must be one of %s" % (cmap, names))
80+
else:
81+
return cmap
7982

8083

8184
def check_size(s):

0 commit comments

Comments
 (0)