@@ -79,7 +79,6 @@ def __gt__(self, other: Self, /) -> bool: ...
79
79
Name = NewType ("Name" , str )
80
80
81
81
# Type aliases
82
- CMAP : TypeAlias = str | Colormap
83
82
RED : TypeAlias = float
84
83
GREEN : TypeAlias = float
85
84
BLUE : TypeAlias = float
@@ -354,7 +353,7 @@ def combine_cmaps(
354
353
355
354
# This function creates a standalone module of a CMasher colormap
356
355
def create_cmap_mod (
357
- cmap : str ,
356
+ cmap : Name ,
358
357
* ,
359
358
save_dir : str | os .PathLike [str ] = "." ,
360
359
_copy_name : str | None = None ,
@@ -978,7 +977,7 @@ def get_cmap_list(cmap_type: str = "all") -> list[str]:
978
977
979
978
980
979
# This function determines the colormap type of a given colormap
981
- def get_cmap_type (cmap : CMAP ) -> str :
980
+ def get_cmap_type (cmap : Colormap | Name ) -> str :
982
981
"""
983
982
Checks what the colormap type (sequential; diverging; cyclic; qualitative;
984
983
misc) of the provided `cmap` is and returns it.
@@ -1060,7 +1059,9 @@ def get_cmap_type(cmap: CMAP) -> str:
1060
1059
1061
1060
1062
1061
# Function create a colormap using a subset of the colors in an existing one
1063
- def get_sub_cmap (cmap : CMAP , start : float , stop : float , * , N : int | None = None ) -> LC :
1062
+ def get_sub_cmap (
1063
+ cmap : Colormap | Name , start : float , stop : float , * , N : int | None = None
1064
+ ) -> LC :
1064
1065
"""
1065
1066
Creates a :obj:`~matplotlib.cm.ListedColormap` object using the colors in
1066
1067
the range `[start, stop]` of the provided `cmap` and returns it.
@@ -1241,7 +1242,7 @@ def sort_key(name):
1241
1242
else :
1242
1243
seen .add (base_str )
1243
1244
1244
- cm_name = base_str [ 3 :]
1245
+ cm_name = Name ( base_str . removeprefix ( "cm_" ))
1245
1246
1246
1247
# Process colormap files
1247
1248
try :
@@ -1276,7 +1277,7 @@ def sort_key(name):
1276
1277
1277
1278
# Check if provided cmap is a cyclic colormap
1278
1279
# If so, obtain its shifted (reversed) versions as well
1279
- if get_cmap_type ("cmr." + cm_name ) == "cyclic" :
1280
+ if get_cmap_type (Name ( "cmr." + cm_name ) ) == "cyclic" :
1280
1281
# Determine the central value index of the colormap
1281
1282
idx = len (rgb ) // 2
1282
1283
@@ -1422,7 +1423,7 @@ def set_cmap_legend_entry(artist: Artist, label: str) -> None:
1422
1423
1423
1424
# Function to take N equally spaced colors from a colormap
1424
1425
def take_cmap_colors (
1425
- cmap : CMAP ,
1426
+ cmap : Colormap | Name ,
1426
1427
N : int | None ,
1427
1428
* ,
1428
1429
cmap_range : tuple [float , float ] = (0 , 1 ),
@@ -1539,7 +1540,7 @@ def take_cmap_colors(
1539
1540
1540
1541
# Function to view what a colormap looks like
1541
1542
def view_cmap (
1542
- cmap : CMAP ,
1543
+ cmap : Colormap | Name ,
1543
1544
* ,
1544
1545
savefig : str | None = None ,
1545
1546
show_test : bool = False ,
0 commit comments