Skip to content

Commit 370f233

Browse files
authored
test: fix matplotlib deprecations (#4091)
1 parent 463b0bb commit 370f233

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
@@ -56,7 +56,8 @@ dependencies = [
5656
"fast-array-utils[accel,sparse]>=1.4",
5757
"h5py>=3.11",
5858
"joblib",
59-
"matplotlib>=3.9",
59+
# skip 3.11.0rc1 for now: https://github.com/matplotlib/matplotlib/issues/31575
60+
"matplotlib>=3.9,!=3.11.0rc1",
6061
"natsort",
6162
"networkx>=2.8.8",
6263
"numba>=0.60",
@@ -260,8 +261,11 @@ filterwarnings = [
260261
"error",
261262
# Umap warns when tensorflow isn’t installed.
262263
"ignore::ImportWarning:umap",
264+
# matplotlib<3.10.7 uses old pyparsing APIs
265+
"ignore::pyparsing.warnings.PyparsingDeprecationWarning",
263266
# seaborn≤0.13.2 causes some matplotlib warnings
264267
"ignore::PendingDeprecationWarning:seaborn",
268+
"ignore:vert.*bool was deprecated:matplotlib.MatplotlibDeprecationWarning:seaborn",
265269
# matplotlib<3.10.4 causes a Pillow warning
266270
"ignore:.*Pillow:DeprecationWarning",
267271
# networkx 2.x warns about scipy.sparse changes
@@ -274,9 +278,7 @@ filterwarnings = [
274278
"ignore:FNV hashing is not implemented in Numba.*:UserWarning",
275279
# we want to see and eventually fix these
276280
"default::numba.core.errors.NumbaPerformanceWarning",
277-
"default:.*TSNE.*random.*to.*pca:FutureWarning", # we should set init=obsm["X_pca"] or so
278-
# matplotlib <3.11 uses old pyparsing APIs
279-
"ignore::pyparsing.warnings.PyparsingDeprecationWarning",
281+
"default:.*TSNE.*random.*to.*pca:FutureWarning", # we should set init=obsm["X_pca"] or so
280282
# igraph vs leidenalg warning
281283
"ignore:The `igraph` implementation of leiden clustering:UserWarning",
282284
# 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
@@ -1292,8 +1292,7 @@ def moving_average(a):
12921292
cmap=matplotlib.colors.ListedColormap(
12931293
# the following line doesn't work because of normalization
12941294
# adata.uns['paga_groups_colors'])
1295-
palette_groups[np.min(groups).astype(int) :],
1296-
N=int(np.max(groups) + 1 - np.min(groups)),
1295+
palette_groups[int(np.min(groups)) : int(np.max(groups)) + 1]
12971296
),
12981297
)
12991298
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
@@ -168,8 +167,7 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915
168167
raise ValueError(msg)
169168
else:
170169
cmap = color_map
171-
cmap = copy(colormaps.get_cmap(cmap))
172-
cmap.set_bad(na_color)
170+
cmap = colormaps.get_cmap(cmap).with_extremes(bad=na_color)
173171
# Prevents warnings during legend creation
174172
na_color = colors.to_hex(na_color, keep_alpha=True)
175173

0 commit comments

Comments
 (0)