From 9048bc7e6c7763a858ac44b6668844886c11f544 Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Mon, 5 Aug 2024 16:23:44 -0400 Subject: [PATCH] Add docstrings --- leafmap/deckgl.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/leafmap/deckgl.py b/leafmap/deckgl.py index 016f67fa15..4557bbc572 100644 --- a/leafmap/deckgl.py +++ b/leafmap/deckgl.py @@ -407,7 +407,22 @@ def add_basemap(self, basemap="HYBRID", visible=True, **kwargs) -> None: def apply_continuous_cmap(values, cmap, alpha=None, rescale=True, **kwargs): + """ + Apply a continuous colormap to a set of values. + + This function rescales the input values to the range [0, 1] if `rescale` is True, + and then applies the specified colormap. + + Args: + values (array-like): The input values to which the colormap will be applied. + cmap (str or Colormap): The colormap to apply. Can be a string name of a matplotlib colormap or a Colormap object. + alpha (float, optional): The alpha transparency to apply to the colormap. Defaults to None. + rescale (bool, optional): If True, rescales the input values to the range [0, 1]. Defaults to True. + **kwargs: Additional keyword arguments to pass to the colormap function. + Returns: + array: The colors mapped to the input values. + """ import numpy as np import matplotlib.pyplot as plt @@ -422,5 +437,18 @@ def apply_continuous_cmap(values, cmap, alpha=None, rescale=True, **kwargs): def apply_categorical_cmap(values, cmap, alpha=None, **kwargs): + """ + Apply a categorical colormap to a set of values. + + This function applies a specified categorical colormap to the input values. + + Args: + values (array-like): The input values to which the colormap will be applied. + cmap (str or Colormap): The colormap to apply. Can be a string name of a matplotlib colormap or a Colormap object. + alpha (float, optional): The alpha transparency to apply to the colormap. Defaults to None. + **kwargs: Additional keyword arguments to pass to the colormap function. + Returns: + array: The colors mapped to the input values. + """ return lonboard.colormap.apply_categorical_cmap(values, cmap, alpha=alpha, **kwargs)