[med-svn] [Git][python-team/packages/python-colormap][master] 4 commits: New upstream version 1.3.0

Colin Watson (@cjwatson) gitlab at salsa.debian.org
Thu Jan 30 11:25:23 GMT 2025



Colin Watson pushed to branch master at Debian Python Team / packages / python-colormap


Commits:
11518290 by Colin Watson at 2025-01-30T11:19:10+00:00
New upstream version 1.3.0
- - - - -
3bfac212 by Colin Watson at 2025-01-30T11:20:57+00:00
Update upstream source from tag 'upstream/1.3.0'

Update to upstream version '1.3.0'
with Debian dir 4c03842664f5d012f7093631360b11fa3ae9632f

- - - - -
9f83ecba by Colin Watson at 2025-01-30T11:23:38+00:00
Ignore debian/files

- - - - -
e502f85e by Colin Watson at 2025-01-30T11:24:16+00:00
releasing package python-colormap version 1.3.0-1

- - - - -


18 changed files:

- .github/workflows/ci.yml
- README.rst
- + debian/.gitignore
- debian/changelog
- debian/copyright
- − debian/patches/poetry-core-2.0.patch
- − debian/patches/series
- doc/requirements.txt
- + doc/source/_static/colormap_logo_256.png
- + doc/source/_static/plot_colormap.png
- doc/source/conf.py
- doc/source/quickstart.rst
- pyproject.toml
- src/colormap/__init__.py
- src/colormap/colors.py
- src/colormap/get_cmap.py
- src/colormap/xfree86.py
- test/test_colors.py


Changes:

=====================================
.github/workflows/ci.yml
=====================================
@@ -13,7 +13,7 @@ jobs:
     strategy:
       max-parallel: 5
       matrix:
-        python: [3.8, 3.9, "3.10", "3.11", "3.12"]
+        python: [3.9, "3.10", "3.11", "3.12"]
       fail-fast: false
 
     steps:


=====================================
README.rst
=====================================
@@ -14,8 +14,17 @@ Please see : http://colormap.readthedocs.io/ for an up-to-date documentation.
 .. image:: https://coveralls.io/repos/cokelaer/colormap/badge.png?branch=main
     :target: https://coveralls.io/r/cokelaer/colormap?branch=main
 
+.. image:: https://static.pepy.tech/personalized-badge/colormap?period=month&units=international_system&left_color=black&right_color=orange&left_text=Downloads
+    :target: https://pepy.tech/project/colormap
 
-:version: Python 3.8, 3.9, 3.10, 3.11, 3.12
+.. image:: http://readthedocs.org/projects/colormap/badge/?version=main
+    :target: http://colormap.readthedocs.org/en/latest/?badge=main
+    :alt: Documentation Status
+
+
+
+
+:version: Python 3.9, 3.10, 3.11, 3.12
 :contributions: Please join https://github.com/cokelaer/colormap
 :issues: Please use https://github.com/cokelaer/colormap/issues
 :notebook: Please see https://github.com/cokelaer/colormap/tree/main/notebooks
@@ -24,11 +33,11 @@ Please see : http://colormap.readthedocs.io/ for an up-to-date documentation.
 What is it ?
 ################
 
-**colormap** package provides simple utilities to convert colors between
-RGB, HEX, HLS, HUV and a class to easily build colormaps for matplotlib. All
-matplotlib colormaps and some R colormaps are available altogether. The
+**colormap** package provides utilities to convert colors between
+RGB, HEX, HLS, HUV and a framework to easily create and build colormaps for matplotlib. All
+matplotlib colormaps and some R colormaps are also available altogether. The
 plot_colormap method (see below) is handy to quickly pick up a colormaps and
-the test_colormap is useful to see test a new colormap.
+the test_colormap is useful to see a live version of the new colormap.
 
 
 Installation
@@ -38,18 +47,34 @@ Installation
 
     pip install colormap
 
-Example
-##########
+Usage examples
+###############
+
+1. convert RGB to HEX:
+
+::
+
+    from colormap import rgb2hex, hex2rgb
+
+    hex_color = rgb2hex(255, 0, 0)  # Red color in HEX
+    print(hex_color)  # Output: "#ff0000"
+
+    rgb_color = hex2rgb("#ff0000")  # Convert back to RGB
+    print(rgb_color)  # Output: (255, 0, 0)
+
+2. Generate a Custom colormap:
 
-* Create your own colormap from red to green colors with intermediate color as
-  whitish (diverging map from red to green)::
+Create your own colormap. For instance, from red to green colors with intermediate color as
+whitish (diverging map from red to green)::
 
+      from colormap import Colormap
       c = Colormap()
       mycmap = c.cmap( {'red':[1,1,0], 'green':[0,1,.39], 'blue':[0,1,0]})
       cmap = c.test_colormap(mycmap)
 
-* Even simpler if the colormap is linear::
+Even simpler if the colormap is linear using color's name::
 
+      from colormap import Colormap
       c = Colormap()
       mycmap = c.cmap_linear('red', 'white', 'green(w3c)')
       cmap = c.test_colormap(mycmap)
@@ -58,15 +83,31 @@ Example
     :width: 50%
     :align: center
 
-* check out the available colormaps::
+3. Visualise existing matplotlib colormap:
 
-      c = Colormap()
-      c.plot_colormap('diverging')
+::
+
+      from colormap import plot_colormap, plot_category
+      plot_colormap("viridis")
+
+
+Using the Colormap instance, you can see all valid names using::
+
+      c.colormaps
+
+Matplotlib is very well known in the PYthon ecosystem and has categorised colormaps into categories such as a
+"diverging". To visualise all of them::
+
+      plot_category('diverging')
 
 .. image:: https://colormap.readthedocs.io/en/latest/_images/quickstart-4.png
     :width: 50%
     :align: center
 
+Other sets of colormaps are : sequentials, sequentials2, misc, diverging, qualitative
+
+
+
 See online documentation for details: http://colormap.readthedocs.io/
 
 changelog
@@ -75,6 +116,9 @@ changelog
 ========= ================================================================================
 Version   Description
 ========= ================================================================================
+1.3.0     * support for poetry 2.0 thanks to @cjwatson PR#26
+          * Slightly better doc
+1.2.0
 1.1.0     * switch to pyproject. remove easydev dependency. compat for python 3.11 and
             3.12
 1.0.6     * Fix a matplotlib deprecation


=====================================
debian/.gitignore
=====================================
@@ -0,0 +1 @@
+/files


=====================================
debian/changelog
=====================================
@@ -1,8 +1,10 @@
-python-colormap (1.2.0-2) UNRELEASED; urgency=medium
+python-colormap (1.3.0-1) unstable; urgency=medium
 
-  * Support poetry-core 2.0 (closes: #1094084).
+  * Team upload.
+  * New upstream release:
+    - Support poetry-core 2.0 (closes: #1094084).
 
- -- Colin Watson <cjwatson at debian.org>  Mon, 27 Jan 2025 20:19:03 +0000
+ -- Colin Watson <cjwatson at debian.org>  Thu, 30 Jan 2025 11:23:50 +0000
 
 python-colormap (1.2.0-1) unstable; urgency=medium
 


=====================================
debian/copyright
=====================================
@@ -3,7 +3,7 @@ Upstream-Name: colormap
 Source: https://pypi.python.org/pypi/colormap
 
 Files: *
-Copyright: 2014 Thomas Cokelaer <cokelaer at gmail.com>
+Copyright: 2014-2024 Thomas Cokelaer <cokelaer at gmail.com>
 License: BSD-3-Clause
 
 Files: debian/*


=====================================
debian/patches/poetry-core-2.0.patch deleted
=====================================
@@ -1,35 +0,0 @@
-From: Colin Watson <cjwatson at debian.org>
-Date: Mon, 27 Jan 2025 20:16:37 +0000
-Subject: Support poetry-core 2.0
-
-Forwarded: https://github.com/cokelaer/colormap/pull/26
-Bug-Debian: https://bugs.debian.org/1094084
-Last-Update: 2025-01-27
----
- pyproject.toml | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
-
-diff --git a/pyproject.toml b/pyproject.toml
-index 7731e91..19726c5 100644
---- a/pyproject.toml
-+++ b/pyproject.toml
-@@ -2,14 +2,17 @@
- requires = ["poetry-core"]
- build-backend = "poetry.core.masonry.api"
- 
--[tool.poetry]
-+[project]
- name = "colormap"
- version = "1.2.0"
- description = "Commn utilities to ease development of Python packages"
--authors = ["Thomas Cokelaer <thomas.cokelaer at pasteur.fr>"]
-+authors = [
-+    { "name" = "Thomas Cokelaer", "email" = "thomas.cokelaer at pasteur.fr" },
-+]
- license = "BSD-3-Clause"
- readme = "README.rst"
- keywords = ["config", "decorators", "development"]
-+dynamic = ["dependencies", "requires-python"]
- 
- classifiers = [
-         "Development Status :: 5 - Production/Stable",


=====================================
debian/patches/series deleted
=====================================
@@ -1 +0,0 @@
-poetry-core-2.0.patch


=====================================
doc/requirements.txt
=====================================
@@ -1,3 +1,4 @@
+numpydoc
 sphinx<7
 sphinx_rtd_theme
 pillow<=10.3.0


=====================================
doc/source/_static/colormap_logo_256.png
=====================================
Binary files /dev/null and b/doc/source/_static/colormap_logo_256.png differ


=====================================
doc/source/_static/plot_colormap.png
=====================================
Binary files /dev/null and b/doc/source/_static/plot_colormap.png differ


=====================================
doc/source/conf.py
=====================================
@@ -16,8 +16,6 @@ import sys
 
 import sphinx
 
-sys.path.insert(0, os.path.abspath("sphinxext"))
-
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -52,8 +50,8 @@ project = "colormap"
 
 extensions = [
     "sphinx.ext.autodoc",
+    "sphinx.ext.imgmath",
     "sphinx.ext.autosummary",
-    "sphinx.ext.graphviz",
     "sphinx.ext.doctest",
     "sphinx.ext.intersphinx",
     "sphinx.ext.todo",
@@ -61,11 +59,6 @@ extensions = [
     "sphinx.ext.ifconfig",
     "sphinx.ext.viewcode",
     "matplotlib.sphinxext.plot_directive",
-    (
-        "sphinx.ext.imgmath"  # only available for sphinx >= 1.4
-        if sphinx.version_info[:2] >= (1, 4)
-        else "sphinx.ext.pngmath"
-    ),
 ]
 # note that the numpy directives is buggy. Example: class and init are not recognised as two entities for the autoclass_content=both here below
 
@@ -135,7 +128,7 @@ show_authors = True
 pygments_style = "sphinx"
 
 # A list of ignored prefixes for module index sorting.
-modindex_common_prefix = ["gdsctools."]
+modindex_common_prefix = ["colormap."]
 
 
 # -- Options for HTML output ---------------------------------------------------
@@ -172,7 +165,7 @@ else:
 
 # The name of an image file (relative to this directory) to place at the top
 # of the sidebar.
-# html_logo = None
+html_logo = "tatic/colormap_logo_256.png"
 
 # The name of an image file (within the static path) to use as favicon of the
 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32


=====================================
doc/source/quickstart.rst
=====================================
@@ -15,7 +15,7 @@ hexadecimal can be encoded as explained in :meth:`colormap.colors.hex2rgb`:
 normalisation
 ---------------
 
-By default, input should be normalised (e.g., RGB values between 0 and 1) and outputs are normalised. 
+By default, input should be normalised (e.g., RGB values between 0 and 1) and outputs are normalised.
 If you provide unnormalised values (e.g., RGB in 0-255) then set the noramlised
 parameter to True (see example in codecs).
 
@@ -58,7 +58,7 @@ format
 
 * RGB (red/green/blue): a triple of values between 0 and 255
 * HLS (): H in 0-360 and L,S in 0-100
-* HSV (): H in 0-360, S,V in 
+* HSV (): H in 0-360, S,V in
 * YUV: all in 0-1
 
 Color class
@@ -97,13 +97,13 @@ Input when instanciating can be anything in RGB, HEX, HLS, common name from
 colormap
 ============
 
-There are lots of colormap in matplotlib. This is great but some may be missing
-or it is not obvious to know what the colormap will look like. 
+There are lots of colormaps in matplotlib. This is great but some may be missing
+or it is not obvious to know what the colormap will look like.
 
 The :class:`colormap.colors.Colormap` class allows you:
 
 - To build easily new colormaps and visualise them
-- Visualise existing colormaps 
+- Visualise existing colormaps
 
 visualise colormaps
 -------------------------
@@ -112,45 +112,52 @@ visualise colormaps
     :include-source:
     :width: 80%
 
-    >>> from colormap import Colormap
-    >>> c = Colormap()
-    >>> c.plot_colormap('sequentials')
+    >>> from colormap import plot_category
+    >>> plot_categoryp('sequentials')
 
 
 .. plot::
     :include-source:
     :width: 80%
 
-    >>> from colormap import Colormap
-    >>> c = Colormap()
-    >>> c.plot_colormap('sequentials2')
+    >>> from colormap import plot_category
+    >>> plot_category('sequentials2')
 
 
 .. plot::
     :include-source:
     :width: 80%
 
-    >>> from colormap import Colormap
-    >>> c = Colormap()
-    >>> c.plot_colormap('misc')
+    >>> from colormap import plot_category
+    >>> plot_category('misc')
 
 
 .. plot::
     :include-source:
     :width: 80%
 
-    >>> from colormap import Colormap
-    >>> c = Colormap()
-    >>> c.plot_colormap('diverging')
+    >>> from colormap import plot_category
+    >>> plot_category('diverging')
 
 
 .. plot::
     :include-source:
     :width: 80%
 
-    >>> from colormap import Colormap
-    >>> c = Colormap()
-    >>> c.plot_colormap('qualitative')
+    >>> from colormap import plot_category
+    >>> plot_category('qualitative')
+
+
+Visualise existing colormap
+-----------------------------
+
+.. plot::
+    :include-source:
+    :width: 80%
+
+    >>> from colormap import plot_colormap,
+    >>> plot_colormap("viridis")
+
 
 
 
@@ -185,7 +192,7 @@ In the previous example, we used 3 colors assuming a linear scale. However, you
 may want a different scale, in which case, you need to provide more colors. In
 such case, you can use :meth:`~colormap.colors.Colormap.cmap` method.
 
-Here we again use the same example a above but it can be generalised easily. 
+Here we again use the same example a above but it can be generalised easily.
 First, we need to know the RGB components of the colors::
 
     >>> from colormap import Color, Colormap
@@ -218,18 +225,3 @@ Finally, test it::
    c = Colormap()
    c.test_colormap(c.cmap({'red':[1,1,0,1], 'green':[0,1,.39,1],
                           'blue':[0,1,0,1]}))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


=====================================
pyproject.toml
=====================================
@@ -2,14 +2,17 @@
 requires = ["poetry-core"]
 build-backend = "poetry.core.masonry.api"
 
-[tool.poetry]
+[project]
 name = "colormap"
-version = "1.2.0"
+version = "1.3.0"
 description = "Commn utilities to ease development of Python packages"
-authors = ["Thomas Cokelaer <thomas.cokelaer at pasteur.fr>"]
+authors = [
+    { "name" = "Thomas Cokelaer", "email" = "thomas.cokelaer at pasteur.fr" },
+]
 license = "BSD-3-Clause"
 readme = "README.rst"
 keywords = ["config", "decorators", "development"]
+dynamic = ["dependencies", "requires-python"]
 
 classifiers = [
         "Development Status :: 5 - Production/Stable",
@@ -45,8 +48,8 @@ matplotlib = [
     {version = "^3", python ="<3.12"},
 ]
 numpy = [
-    {version = "^2", python ="^3.9"},
-    {version = "<2,", python ="<3.9"}
+    {version = "^2", python ="^3.10"},
+    {version = "<2,", python ="<3.10"}
 ]
 importlib_resources = [
     {version = ">6", python=">=3.9,<=3.10"}


=====================================
src/colormap/__init__.py
=====================================
@@ -3,7 +3,7 @@
 #
 # This file is part of the colormap software
 #
-# Copyright (c) 2014
+# Copyright (c) 2014-2-24
 #
 # File author(s): Thomas Cokelaer <cokelaer at gmail.com>
 #
@@ -22,7 +22,7 @@ def get_package_version(package_name):
     try:
         version = metadata.version(package_name)
         return version
-    except metadata.PackageNotFoundError:
+    except metadata.PackageNotFoundError:  # pragma: no cover
         return f"{package_name} not found"
 
 


=====================================
src/colormap/colors.py
=====================================
@@ -3,7 +3,7 @@
 #
 #  This file is part of the colormap software
 #
-#  Copyright (c) 2011-20134
+#  Copyright (c) 2011-2024
 #
 #  File author(s): Thomas Cokelaer <cokelaer at gmail.com>
 #
@@ -43,6 +43,8 @@ __all__ = [
     "yuv2rgb_int",
     "rgb2yuv_int",
     "Colormap",
+    "plot_category",
+    "plot_colormap",
 ]
 
 
@@ -62,37 +64,11 @@ def swapdict(dic, check_ambiguity=True):
 
     """
     # this version is more elegant but slightly slower : return {v:k for k,v in dic.items()}
-    if check_ambiguity:
+    if check_ambiguity:  # pragma: no cover
         assert len(set(dic.keys())) == len(set(dic.values())), "values is not a set. ambiguities for keys."
     return dict(zip(dic.values(), dic.keys()))
 
 
-def check_param_in_list(param, valid_values, name=None):
-    """Checks that the value of param is amongst valid
-
-    :param param: a parameter to be checked
-    :param list valid_values: a list of values
-
-    ::
-
-        check_param_in_list(1, [1,2,3])
-        check_param_in_list(mode, ["on", "off"])
-    """
-    if isinstance(valid_values, list) is False:
-
-        raise TypeError(
-            "the valid_values second argument must be a list of valid values. {0} was provided.".format(valid_values)
-        )
-
-    if param not in valid_values:
-        if name:
-            msg = "Incorrect value provided for {} ({})".format(name, param)
-        else:
-            msg = "Incorrect value provided (%s)" % param
-        msg += "    Correct values are %s" % valid_values
-        raise ValueError(msg)
-
-
 def hex2web(hexa):
     """Convert hexadecimal string (6 digits) into *web* version (3 digits)
 
@@ -334,7 +310,7 @@ def hls2rgb(h, l, s, normalised=True):
 def hex2dec(data):
     """convert hexadecimal string (data) into a float in the [0-65536] inclusive range"""
     if data[0] == "#":
-        data.replace("#", "")
+        data = data.replace("#", "")
     return int(data, 16) / 255
 
 
@@ -417,7 +393,7 @@ def yuv2rgb_int(y, u, v):
 
 
 def _denormalise(r, g, b, mode="rgb"):
-    check_param_in_list(mode, ["rgb", "hls", "hsv"])
+    assert mode in ["rgb", "hls", "hsv"], f"Please provide valid mode in [rgb, hls, hsv]. you provided {mode}"
     if mode == "rgb":
         return r * 255, g * 255, b * 255
     elif mode in ["hls", "hsv"]:
@@ -425,7 +401,7 @@ def _denormalise(r, g, b, mode="rgb"):
 
 
 def _normalise(r, g, b, mode="rgb"):
-    check_param_in_list(mode, ["rgb", "hls", "hsv"])
+    assert mode in ["rgb", "hls", "hsv"], f"Please provide valid mode in [rgb, hls, hsv]. you provided {mode}"
     if mode == "rgb":
         return r / 255, g / 255, b / 255
     elif mode in ["hls", "hsv"]:
@@ -596,7 +572,7 @@ class Color(HEX):
         return self._name
 
     def _set_name(self, name):
-        check_param_in_list(name, self.color_names)
+        assert name in self.color_names, f"Please provide valid name from {self.color_names}. you provided {name}"
         name = self.aliases[name]
         self._name = name
         # set hex and rgb at the same time based on the name
@@ -744,7 +720,20 @@ class Color(HEX):
         return txt
 
 
-class Colormap(object):
+def plot_category(name):
+    c = Colormap()
+    assert name in c.categories, f"Use one of {c.categories}. you provided {name}"
+    c.plot_colormap(name)
+    from pylab import title
+
+
+def plot_colormap(name):
+    c = Colormap()
+    assert name in c.colormaps, f"Use one of {c.colormaps}. you provided {name}"
+    c.test_colormap(name)
+
+
+class Colormap:
     """Class to create matplotlib colormap
 
     This example show how to get the pre-defined colormap called *heat*
@@ -799,16 +788,38 @@ class Colormap(object):
         http://matplotlib.org/examples/color/colormaps_reference.html
     """
 
+    def __init__(self):
+        self.categories = [
+            "sequentials2",
+            "sequentials",
+            "misc",
+            "diverging_black",
+            "perceptually_uniform",
+            "diverging",
+            "cyclic",
+            "qualitative",
+        ]
+
     def _get_colormap_mpl(self):
         try:
             from matplotlib.pyplot import colormaps as _cmaps
 
             return _cmaps()
-        except:
+        except Exception:  # pragma: no cover
             return []
 
     colormaps = property(_get_colormap_mpl)
 
+    def _get_cyclic(self):
+        return ["twilight", "twilight_shifted", "hsv"]
+
+    cyclic = property(_get_cyclic)
+
+    def _get_perceptually_uniform(self):
+        return ["viridis", "plasma", "inferno", "magma", "cividis"]
+
+    perceptually_uniform = property(_get_perceptually_uniform)
+
     def _get_sequentials(self):
         return [
             "Blues",
@@ -837,16 +848,19 @@ class Colormap(object):
         return [
             "afmhot",
             "autumn",
+            "binary",
             "bone",
             "cool",
             "copper",
             "gist_heat",
+            "gist_gray",
             "gray",
             "hot",
             "pink",
             "spring",
             "summer",
             "winter",
+            "Wistia",
         ]
 
     sequentials2 = property(_get_sequentials2)
@@ -1086,14 +1100,41 @@ class Colormap(object):
         if cmap is None:
             cmap = self.get_cmap_heat()
         import numpy as np
-        from pylab import axis, clf, colorbar, linspace, pcolor, show
+        from pylab import axis, clf, colorbar, linspace, pcolor, show, subplots
 
         A, B = np.meshgrid(linspace(0, 10, 100), linspace(0, 10, 100))
-        clf()
-        pcolor((A - 5) ** 2 + (B - 5) ** 2, cmap=cmap)
-        colorbar()
-        # show()
-        axis("off")
+        fig, ax = subplots(2, 2)
+        ax[0, 0].pcolor((A - 5) ** 2 + (B - 5) ** 2, cmap=cmap)
+        ax[0, 0].axis("off")
+        ax[0, 0].set_title("Linear map in 2D")
+
+        gradient = np.linspace(0, 1, 256)
+        gradient = np.vstack((gradient, gradient))
+        ax[0, 1].imshow(gradient, cmap=cmap, aspect="auto")
+        ax[0, 1].axis("off")
+        ax[0, 1].set_title("Linear map in 1D")
+
+        # Define the sinc function
+        def sinc_2d(x, y):
+            r = np.sqrt(x**2 + y**2)  # Compute radial distance
+            return np.sinc(r)  # sinc(x) in NumPy is already sin(pi*x) / (pi*x)
+
+        # Generate a grid
+        x = np.linspace(-5, 5, 200)
+        y = np.linspace(-5, 5, 200)
+        X, Y = np.meshgrid(x, y)
+        Z = sinc_2d(X, Y)  # Compute sinc values
+        ax[1, 0].imshow(Z, origin="lower", cmap=cmap)
+        ax[1, 0].axis("off")
+        ax[1, 0].set_title("Sinus cardinal")
+
+        N = 100
+        X = np.random.random(N)
+        Y = np.random.random(N)
+        C = np.random.random(N)
+        ax[1, 1].scatter(X, Y, c=C * 10, cmap=cmap)
+        ax[1, 1].set_title("random scatter plot")
+        ax[1, 1].axis("off")
 
     def plot_colormap(self, cmap_list=None):
         """cmap_list list of valid cmap or name of a set (sequential,
@@ -1114,17 +1155,19 @@ class Colormap(object):
         from pylab import subplots
 
         if isinstance(cmap_list, str):
-            if cmap_list in ["sequentials", "sequentials2", "qualitative", "misc", "diverging", "diverging_black"]:
+            if cmap_list in self.categories:
+                colormap = cmap_list
                 cmap_list = getattr(self, cmap_list)
             else:
+                colormap = "custom"
                 cmap_list = [cmap_list]
-        if isinstance(cmap_list, list) is not True:
+        if isinstance(cmap_list, list) is not True:  # pragma: no cover
             raise TypeError(
                 """input must be a list of srtings or a single string. Each string should be found. For a user-defined cmap, use test_colormap"""
             )
         for this in cmap_list:
             if this not in self.colormaps and this not in self.diverging_black:
-                raise ValueError("unknown colormap name. Please check valid names in colormaps attribute")
+                raise ValueError(f"unknown colormap name {this}. Please check valid names in colormaps attribute")
 
         nrows = len(cmap_list)
 
@@ -1134,6 +1177,7 @@ class Colormap(object):
 
         fig, axes = subplots(nrows=nrows)
         fig.subplots_adjust(top=0.95, bottom=0.05, left=0.05, right=0.8)
+        axes[0].set_title(f"{colormap} colormaps")
 
         for ax, name in zip(axes, cmap_list):
             ax.imshow(gradient, aspect="auto", cmap=self.cmap(name))


=====================================
src/colormap/get_cmap.py
=====================================
@@ -2,7 +2,7 @@
 #
 #  This file is part of colormap software
 #
-#  Copyright (c) 2014L
+#  Copyright (c) 2011-2024
 #
 #  File author(s): Thomas Cokelaer <cokelaer at gmail.com>
 #
@@ -31,7 +31,7 @@ def cmap_builder(name, name2=None, name3=None):
     c = Colormap()
 
     # if the colormap is already a colormap, nothing to do
-    try:
+    try:  # pragma: no cover
         name.get_bad()
         return name
     except AttributeError:
@@ -52,7 +52,7 @@ def cmap_builder(name, name2=None, name3=None):
     # some custom diverging colormaps with black in the middle.
     elif name in c.diverging_black:
         return c.cmap(name)
-    elif name.count("_") == 2:
+    elif name.count("_") == 2:  # pragma: no cover
         name1, name2, name3 = name.split("_")
         return c.cmap_linear(name1, name2, name3)
     else:


=====================================
src/colormap/xfree86.py
=====================================
@@ -3,7 +3,7 @@
 #
 # This file is part of the colormap software
 #
-# Copyright (c) 2014
+# Copyright (c) 2014-2024
 #
 # File author(s): Thomas Cokelaer <cokelaer at gmail.com>
 #


=====================================
test/test_colors.py
=====================================
@@ -38,6 +38,7 @@ def test_rgb2hls():
 
 def test_hex2dec():
     assert colors.hex2dec("FF") == 1
+    assert colors.hex2dec("#FF") == 1
 
 
 def test_rgb2hex():
@@ -165,6 +166,21 @@ def test_to_intensity():
     to_intensity(0.5)
 
 
+def test_plot_colormap():
+    plot_colormap("jet")
+    plot_colormap("jet_r")
+
+    try:
+        plot_colormap("dummy")
+        assert False
+    except (AssertionError, TypeError):
+        assert True
+
+
+def test_plot_category():
+    plot_category("diverging")
+
+
 def test_colormap():
     try:
         from pylab import clf, close, gcf
@@ -179,6 +195,10 @@ def test_colormap():
     # design your own colormap
     d = {"blue": [0, 0, 0, 1, 1, 1, 0], "green": [0, 1, 1, 1, 0, 0, 0], "red": [1, 1, 0, 0, 0, 1, 1]}
     cmap = c.cmap(d, reverse=True)
+
+    cmap = c.cmap("jet", reverse=True)
+    cmap = c.cmap("heat")
+    cmap = c.cmap("heat_r")
     cmap = c.get_cmap_rainbow()
     cmap = c.get_cmap_red_green()
     cmap = c.get_cmap_heat_r()
@@ -208,13 +228,20 @@ def test_colormap():
     # FIXME: need to find a way to close the plot. close('all') does not work
     # c.plot_rgb_from_hex_list(t)
     c.plot_colormap("misc")
-    # c.plot_colormap('jet')
+    try:
+        c.plot_colormap("dummy")
+        assert False
+    except ValueError:
+        pass
+
     c.test_colormap("jet")
     c.diverging
     c.colormaps
     c.sequentials
     c.sequentials2
     c.qualitative
+    c.cyclic
+    c.perceptually_uniform
 
     t = [
         "#FF0000FF",



View it on GitLab: https://salsa.debian.org/python-team/packages/python-colormap/-/compare/ee2dc0fd69724200d59083cd86abf3a3e26e0033...e502f85e9f58e4515402b960b3ba9f918e6084ee

-- 
View it on GitLab: https://salsa.debian.org/python-team/packages/python-colormap/-/compare/ee2dc0fd69724200d59083cd86abf3a3e26e0033...e502f85e9f58e4515402b960b3ba9f918e6084ee
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20250130/4b52186b/attachment-0001.htm>


More information about the debian-med-commit mailing list