From 07629fc010d5edf6b6383defd401b368cb698ff6 Mon Sep 17 00:00:00 2001 From: Xin Xiong Date: Fri, 18 Jun 2021 11:05:08 +0800 Subject: [PATCH 1/2] Update _utils.py Better strategy to compare two 3-dimensional arrays, such as `RGB` color list `[array([0.29803922, 0.44705882, 0.69019608]), array([0.86666667, 0.51764706, 0.32156863]), array([0.33333333, 0.65882353, 0.40784314]), array([0.76862745, 0.30588235, 0.32156863])]`. --- scanpy/plotting/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scanpy/plotting/_utils.py b/scanpy/plotting/_utils.py index eaaa4ba32f..039ceb9543 100644 --- a/scanpy/plotting/_utils.py +++ b/scanpy/plotting/_utils.py @@ -355,7 +355,7 @@ def _validate_palette(adata, key): break _palette.append(color) # Don't modify if nothing changed - if _palette is not None and list(_palette) != list(adata.uns[color_key]): + if _palette is not None and np.all(np.array(_palette) != np.array(adata.uns[color_key])): adata.uns[color_key] = _palette From d275026318184f377221c8be309215324ae34b7d Mon Sep 17 00:00:00 2001 From: Xin Xiong Date: Fri, 18 Jun 2021 11:08:19 +0800 Subject: [PATCH 2/2] Update _utils.py The logic should be `np.any()` instead of `np.all()`. --- scanpy/plotting/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scanpy/plotting/_utils.py b/scanpy/plotting/_utils.py index 039ceb9543..d9f0db1114 100644 --- a/scanpy/plotting/_utils.py +++ b/scanpy/plotting/_utils.py @@ -355,7 +355,7 @@ def _validate_palette(adata, key): break _palette.append(color) # Don't modify if nothing changed - if _palette is not None and np.all(np.array(_palette) != np.array(adata.uns[color_key])): + if _palette is not None and np.any(np.array(_palette) != np.array(adata.uns[color_key])): adata.uns[color_key] = _palette