playnano.utils.colormaps module¶
Utilities for loading, registering, and validating custom colormaps.
This module provides helper functions to register custom colormaps shipped with the playNano package, validate colormap names, and safely resolve user-provided colormap inputs with sensible fallbacks.
- playnano.utils.colormaps.get_available_cmaps() list[str][source]¶
Return a sorted list of available colormap names.
This includes all built-in Matplotlib colormaps as well as any custom colormaps that have been registered.
- playnano.utils.colormaps.is_valid_cmap(name: str) bool[source]¶
Check whether a colormap name is available in Matplotlib.
This includes both: - Built-in Matplotlib colormaps - Custom playNano colormaps (if registered)
- playnano.utils.colormaps.register_custom_colormaps() None[source]¶
Load and register all custom playNano colormaps.
Colormap definitions are stored as CSV files within the
playnano.resources.colormapspackage. Each colormap is registered globally with Matplotlib under its canonical name, along with a reversed variant (<name>_r).This function is safe to call multiple times; colormaps that are already registered will not be re-registered.
Any failures encountered while loading individual colormaps are logged as errors, but do not prevent remaining colormaps from being processed.
- Return type:
None
- playnano.utils.colormaps.resolve_cmap(cmap: str) str[source]¶
Resolve a user-provided colormap name to a valid colormap.
If the requested colormap is not recognized, a warning is logged and a default colormap is returned instead. This function never raises an exception and always returns a usable colormap name.
- Parameters:
cmap (str) – Name of the requested colormap.
- Returns:
A valid colormap name. If cmap is invalid or unknown, this will be DEFAULT_CMAP.
- Return type:
Notes
This function is intended for user-facing inputs (e.g. CLI arguments, configuration files, or API parameters) where robustness is preferred over strict validation.
See also
is_valid_cmapCheck whether a colormap name is supported.
DEFAULT_CMAPDefault colormap used as a fallback.