Repository: theislab/cellrank (language: python)

Issue:
Wrong colors for macrostate composition per time step
<!-- Please give a clear and concise description of the bug: -->
## Description

When running the tutorial for time-series datasets [here](https://cellrank.readthedocs.io/en/stable/real_time.html) the colors stored for each `day` are all the same. This leads to the plot produced by `g.plot_macrostate_composition(key="day")` be incorrect/uninformative.

### Expected plot

![image](https://user-images.githubusercontent.com/28675704/144439637-6541ed76-4fa8-4f5f-bf4e-f77abf57e4c1.png)

### Actual plot

![image](https://user-images.githubusercontent.com/28675704/144439588-c0015a8c-da45-4d1d-9a08-f727f463f209.png)

#### Versions:
<!-- Output of cellrank.logging.print_versions() -->
> cellrank==1.5.0+g10479a98.d20211116 scanpy==1.8.1 anndata==0.7.6 numpy==1.21.1 numba==0.52.0 scipy==1.7.0 pandas==1.3.1 pygpcca==1.0.2 scikit-learn==0.24.2 statsmodels==0.12.2 python-igraph==0.9.8 scvelo==0.2.3 pygam==0.8.0 matplotlib==3.4.2 seaborn==0.11.1



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/news.yml b/.github/workflows/news.yml
index 695327cea..e1f4afc8c 100644
--- a/.github/workflows/news.yml
+++ b/.github/workflows/news.yml
@@ -47,12 +47,12 @@ jobs:
                 skip_dirty_check: false
 
         -   name: Update dev release notes
-            if: ${{ steps.auto-commit-action.outputs.changes_detected == 'true' && contains(github.base_ref, 'dev') }}
+            if: ${{ contains(github.base_ref, 'dev') }}
             run: |
                 tox -e update-dev-notes
 
         -   name: Commit dev release notes
-            if: ${{ steps.auto-commit-action.outputs.changes_detected == 'true' && contains(github.base_ref, 'dev') }}
+            if: ${{ contains(github.base_ref, 'dev') }}
             uses: stefanzweifel/git-auto-commit-action@v4
             with:
                 commit_message: ${{ format('[auto][ci skip] Update dev release notes (#{0})', github.event.number) }}
diff --git a/cellrank/tl/kernels/_exp_time_kernel.py b/cellrank/tl/kernels/_exp_time_kernel.py
index ad4adee75..e6c1452dc 100644
--- a/cellrank/tl/kernels/_exp_time_kernel.py
+++ b/cellrank/tl/kernels/_exp_time_kernel.py
@@ -68,7 +68,7 @@ def _read_from_adata(self, **kwargs: Any) -> None:
         cmap = get_cmap(kwargs.pop("cmap", "gnuplot"))
         cats = self.experimental_time.cat.categories
         norm = Normalize(vmin=cats.min(), vmax=cats.max())
-        self.adata.uns[f"{time_key}_colors"] = np.array([to_hex(c) for c in cmap(norm(cats) * cmap.N)])
+        self.adata.uns[f"{time_key}_colors"] = np.array([to_hex(c) for c in cmap(norm(cats))])
         # fmt: on
 
     @d.dedent


Test patch:
diff --git a/tests/test_external.py b/tests/test_external.py
index 66b390398..7c54a623b 100644
--- a/tests/test_external.py
+++ b/tests/test_external.py
@@ -14,6 +14,7 @@
 from scipy.sparse import csr_matrix
 from pandas.core.dtypes.common import is_categorical_dtype
 
+import matplotlib.pyplot as plt
 from matplotlib.cm import get_cmap
 from matplotlib.colors import to_hex
 
@@ -353,6 +354,23 @@ def test_wot_write(self, adata_large: AnnData, tmpdir):
         )
         np.testing.assert_array_equal(ok.transition_matrix.A, ok2.transition_matrix.A)
 
+    @pytest.mark.parametrize("cmap", ["viridis", "inferno"])
+    @pytest.mark.parametrize("size", [5, 10])
+    def test_colormap(self, adata_large: AnnData, cmap: str, size: int):
+        dummy_time = pd.cut(adata_large.obs["latent_time"], size).cat.rename_categories(
+            range(13, 13 + size)
+        )
+        adata_large.obs["dummy_time"] = dummy_time
+        expected_colors = [
+            to_hex(c) for c in plt.get_cmap(cmap)(np.linspace(0.0, 1.0, size))
+        ]
+
+        _ = cre.kernels.WOTKernel(adata_large, time_key="dummy_time", cmap=cmap)
+
+        np.testing.assert_array_equal(
+            adata_large.uns["dummy_time_colors"], expected_colors
+        )
+
 
 class TestGetMarkers:
     @pytest.mark.parametrize("kind", ["proliferation", "apoptosis"])