Skip to content

Commit 2b4581d

Browse files
authored
Backport PR #4091 on branch 1.12.x (test: fix matplotlib deprecations) (#4092)
1 parent 8f30be6 commit 2b4581d

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ dependencies = [
5757
"h5py>=3.11",
5858
"joblib",
5959
"legacy-api-wrap>=1.5", # for positional API deprecations
60-
"matplotlib>=3.9",
60+
# skip 3.11.0rc1 for now: https://github.com/matplotlib/matplotlib/issues/31575
61+
"matplotlib>=3.9,!=3.11.0rc1",
6162
"natsort",
6263
"networkx>=2.8.8",
6364
"numba>=0.60",
@@ -259,8 +260,11 @@ filterwarnings = [
259260
"error",
260261
# Umap warns when tensorflow isn’t installed.
261262
"ignore::ImportWarning:umap",
263+
# matplotlib<3.10.7 uses old pyparsing APIs
264+
"ignore::pyparsing.warnings.PyparsingDeprecationWarning",
262265
# seaborn≤0.13.2 causes some matplotlib warnings
263266
"ignore::PendingDeprecationWarning:seaborn",
267+
"ignore:vert.*bool was deprecated:matplotlib.MatplotlibDeprecationWarning:seaborn",
264268
# matplotlib<3.10.4 causes a Pillow warning
265269
"ignore:.*Pillow:DeprecationWarning",
266270
# networkx 2.x warns about scipy.sparse changes
@@ -273,9 +277,7 @@ filterwarnings = [
273277
"ignore:FNV hashing is not implemented in Numba.*:UserWarning",
274278
# we want to see and eventually fix these
275279
"default::numba.core.errors.NumbaPerformanceWarning",
276-
"default:.*TSNE.*random.*to.*pca:FutureWarning", # we should set init=obsm["X_pca"] or so
277-
# matplotlib <3.11 uses old pyparsing APIs
278-
"ignore::pyparsing.warnings.PyparsingDeprecationWarning",
280+
"default:.*TSNE.*random.*to.*pca:FutureWarning", # we should set init=obsm["X_pca"] or so
279281
# igraph vs leidenalg warning
280282
"ignore:The `igraph` implementation of leiden clustering:UserWarning",
281283
# everybody uses this zarr 3 feature, including us, XArray, lots of data out there …

src/scanpy/plotting/_tools/paga.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,7 @@ def moving_average(a):
13581358
cmap=matplotlib.colors.ListedColormap(
13591359
# the following line doesn't work because of normalization
13601360
# adata.uns['paga_groups_colors'])
1361-
palette_groups[np.min(groups).astype(int) :],
1362-
N=int(np.max(groups) + 1 - np.min(groups)),
1361+
palette_groups[int(np.min(groups)) : int(np.max(groups)) + 1]
13631362
),
13641363
)
13651364
if show_yticks:

src/scanpy/plotting/_tools/scatterplots.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55
import textwrap
66
from collections.abc import Sequence
7-
from copy import copy
87
from functools import cache, partial
98
from itertools import combinations, product
109
from numbers import Integral
@@ -169,8 +168,7 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915
169168
raise ValueError(msg)
170169
else:
171170
cmap = color_map
172-
cmap = copy(colormaps.get_cmap(cmap))
173-
cmap.set_bad(na_color)
171+
cmap = colormaps.get_cmap(cmap).with_extremes(bad=na_color)
174172
# Prevents warnings during legend creation
175173
na_color = colors.to_hex(na_color, keep_alpha=True)
176174

0 commit comments

Comments
 (0)