diff --git a/pyproject.toml b/pyproject.toml index d105f6559e..c5f7d93537 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,7 @@ dependencies = [ "pynndescent>=0.5.13", "scikit-learn>=1.6", "scipy>=1.13", + "scverse-misc>=0.0.5", "seaborn>=0.13.2", "session-info2", "statsmodels>=0.14.5", @@ -230,6 +231,7 @@ lint.pylint.max-positional-args = 5 "scipy.sparse.sparray".msg = "Use _compat.SpBase instead" "scipy.sparse.spmatrix".msg = "Use _compat.SpBase instead" "warnings.warn".msg = "Use `scanpy._compat.warn` instead" +"warnings.deprecated".msg = "Use `scverse_misc.deprecated` instead" [tool.pyproject-fmt] indent = 4 diff --git a/src/scanpy/_compat.py b/src/scanpy/_compat.py index 31cdd1757a..1c91dca2c8 100644 --- a/src/scanpy/_compat.py +++ b/src/scanpy/_compat.py @@ -1,6 +1,5 @@ from __future__ import annotations -import sys import warnings from functools import cache, partial from importlib.util import find_spec @@ -21,7 +20,6 @@ "CSRBase", "DaskArray", "SpBase", - "deprecated", "fullname", "old_positionals", "pkg_metadata", @@ -89,18 +87,6 @@ def pkg_version(package: str) -> Version: ) -# we’re not using _FILE_PREFIXES here, -# since a wholesale deprecated function shouldn’t be used internally anyway -if TYPE_CHECKING: - from warnings import deprecated -else: - if sys.version_info >= (3, 13): - from warnings import deprecated as _deprecated - else: - from typing_extensions import deprecated as _deprecated - deprecated = partial(_deprecated, category=FutureWarning) - - def warn( message: str, category: type[Warning], diff --git a/src/scanpy/_settings/__init__.py b/src/scanpy/_settings/__init__.py index 2c43b2d74c..30b8a61aed 100644 --- a/src/scanpy/_settings/__init__.py +++ b/src/scanpy/_settings/__init__.py @@ -7,8 +7,10 @@ from time import time from typing import TYPE_CHECKING, Literal, get_args +from scverse_misc import Deprecation, deprecated + from .. import logging -from .._compat import deprecated, old_positionals +from .._compat import old_positionals from .._singleton import SingletonMeta, documenting from ..logging import _RootLogger, _set_log_file, _set_log_level from .verbosity import Verbosity @@ -330,7 +332,7 @@ def categories_to_ignore(cls, categories_to_ignore: Iterable[str]) -> None: # Functions # -------------------------------------------------------------------------------- - @deprecated("Use `scanpy.set_figure_params` instead") + @deprecated(Deprecation("1.11.3", "Use :func:`scanpy.set_figure_params` instead")) def set_figure_params(cls, *args, **kwargs) -> None: cls._set_figure_params(*args, **kwargs) diff --git a/src/scanpy/_settings/verbosity.py b/src/scanpy/_settings/verbosity.py index c74c19f141..109dc7bd93 100644 --- a/src/scanpy/_settings/verbosity.py +++ b/src/scanpy/_settings/verbosity.py @@ -5,7 +5,7 @@ from logging import getLevelNamesMapping from typing import TYPE_CHECKING -from .._compat import deprecated +from scverse_misc import Deprecation, deprecated if TYPE_CHECKING: from collections.abc import Generator @@ -29,7 +29,7 @@ class VerbosityMeta(EnumMeta): @property - @deprecated("Use `Verbosity.warning` instead") + @deprecated(Deprecation("1.11.3", "Use :attr:`~scanpy.Verbosity.warning` instead")) def warn(cls) -> Verbosity: return Verbosity.warning diff --git a/src/scanpy/datasets/_datasets.py b/src/scanpy/datasets/_datasets.py index 36b85df1e8..81efe42ede 100644 --- a/src/scanpy/datasets/_datasets.py +++ b/src/scanpy/datasets/_datasets.py @@ -8,12 +8,13 @@ import pandas as pd from anndata import AnnData, OldFormatWarning from packaging.version import Version +from scverse_misc import Deprecation, deprecated from .. import _utils -from .._compat import deprecated, old_positionals, pkg_version +from .._compat import old_positionals, pkg_version from .._settings import settings from .._utils._doctests import doctest_internet, doctest_needs, doctest_skipif -from ..readwrite import read, read_h5ad, read_visium +from ..readwrite import read, read_h5ad from ._utils import check_datasetdir_exists if TYPE_CHECKING: @@ -532,7 +533,7 @@ def _download_visium_dataset( return sample_dir -@deprecated("Use `squidpy.datasets.visium` instead.") +@deprecated(Deprecation("1.11.0", "Use :func:`squidpy.datasets.visium` instead.")) @_doctest_skipif_old_anndata @doctest_internet @check_datasetdir_exists @@ -543,9 +544,6 @@ def visium_sge( ) -> AnnData: """Processed Visium Spatial Gene Expression data from 10x Genomics’ database. - .. deprecated:: 1.11.0 - Use :func:`squidpy.datasets.visium` instead. - The database_ can be browsed online to find the ``sample_id`` you want. .. _database: https://support.10xgenomics.com/spatial-gene-expression/datasets @@ -566,7 +564,7 @@ def visium_sge( -------- >>> import scanpy as sc >>> sc.datasets.visium_sge(sample_id="V1_Breast_Cancer_Block_A_Section_1") - FutureWarning: Use `squidpy.datasets.visium` instead. + FutureWarning: The function visium_sge is deprecated and will be removed in the future. Use :func:`squidpy.datasets.visium` instead. sc.datasets.visium_sge(sample_id="V1_Breast_Cancer_Block_A_Section_1") UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`. ... @@ -578,6 +576,8 @@ def visium_sge( layers: None """ # noqa: D401 + from ..readwrite import read_visium + spaceranger_version = "1.1.0" if "V1_" in sample_id else "1.2.0" sample_dir = _download_visium_dataset( sample_id, spaceranger_version, download_image=include_hires_tiff diff --git a/src/scanpy/external/pl.py b/src/scanpy/external/pl.py index 73d63a2bff..398594cda1 100644 --- a/src/scanpy/external/pl.py +++ b/src/scanpy/external/pl.py @@ -7,11 +7,12 @@ import matplotlib.pyplot as plt import numpy as np +from scverse_misc import Deprecation, deprecated -from .._compat import deprecated, old_positionals +from .._compat import old_positionals from .._utils import _doc_params from .._utils._doctests import doctest_needs -from ..plotting import _scrublet, _utils, embedding +from ..plotting import _utils, embedding from ..plotting._docs import ( doc_adata_color_etc, doc_edges_arrows, @@ -357,6 +358,8 @@ def wishbone_marker_trajectory( # noqa: PLR0913 return ax -scrublet_score_distribution = deprecated("Import from sc.pl instead")( - _scrublet.scrublet_score_distribution -) +@deprecated(Deprecation("1.10.0", "Import from sc.pl instead.")) +def scrublet_score_distribution(*args, **kwargs): # pragma: no cover + from ..plotting._scrublet import scrublet_score_distribution + + return scrublet_score_distribution(*args, **kwargs) diff --git a/src/scanpy/external/pp/__init__.py b/src/scanpy/external/pp/__init__.py index a8b09f725d..a58fa577ea 100644 --- a/src/scanpy/external/pp/__init__.py +++ b/src/scanpy/external/pp/__init__.py @@ -2,8 +2,8 @@ from __future__ import annotations -from ..._compat import deprecated -from ...preprocessing import _scrublet +from scverse_misc import Deprecation, deprecated + from ._bbknn import bbknn from ._dca import dca from ._harmony_integrate import harmony_integrate @@ -12,11 +12,6 @@ from ._mnn_correct import mnn_correct from ._scanorama_integrate import scanorama_integrate -scrublet = deprecated("Import from sc.pp instead")(_scrublet.scrublet) -scrublet_simulate_doublets = deprecated("Import from sc.pp instead")( - _scrublet.scrublet_simulate_doublets -) - __all__ = [ "bbknn", "dca", @@ -26,3 +21,17 @@ "mnn_correct", "scanorama_integrate", ] + + +@deprecated(Deprecation("1.10.0", "Import from sc.pp instead.")) +def scrublet(*args, **kwargs): + from ...preprocessing import scrublet + + return scrublet(*args, **kwargs) + + +@deprecated(Deprecation("1.10.0", "Import from sc.pp instead.")) +def scrublet_simulate_doublets(*args, **kwargs): + from ...preprocessing import scrublet_simulate_doublets + + return scrublet_simulate_doublets(*args, **kwargs) diff --git a/src/scanpy/logging.py b/src/scanpy/logging.py index 6086b19b82..383160396a 100644 --- a/src/scanpy/logging.py +++ b/src/scanpy/logging.py @@ -11,8 +11,7 @@ from typing import TYPE_CHECKING, overload import anndata.logging - -from ._compat import deprecated +from scverse_misc import Deprecation, deprecated if TYPE_CHECKING: from typing import IO @@ -158,14 +157,9 @@ def print_header(*, file: IO[str] | None = None): return sinfo -@deprecated("Use `print_header` instead") +@deprecated(Deprecation("1.11.0", "Use :func:`print_header` instead.")) def print_versions() -> SessionInfo: - """Alias for `print_header`. - - .. deprecated:: 1.11.0 - - Use :func:`print_header` instead. - """ + """Alias for `print_header`.""" return print_header() diff --git a/src/scanpy/plotting/__init__.py b/src/scanpy/plotting/__init__.py index d9cf162abf..4f3d79024f 100644 --- a/src/scanpy/plotting/__init__.py +++ b/src/scanpy/plotting/__init__.py @@ -2,7 +2,8 @@ from __future__ import annotations -from .._compat import deprecated +from scverse_misc import Deprecation, deprecated + from . import palettes from ._anndata import ( clustermap, @@ -54,7 +55,7 @@ tsne, umap, ) -from ._utils import matrix, timeseries, timeseries_as_heatmap, timeseries_subplot +from ._utils import matrix __all__ = [ "DotPlot", @@ -107,6 +108,23 @@ "violin", ] -timeseries = deprecated("Use `dpt_timeseries`.")(timeseries) -timeseries_as_heatmap = deprecated("Use `dpt_timeseries`.")(timeseries_as_heatmap) -timeseries_subplot = deprecated("Use `dpt_timeseries`.")(timeseries_subplot) + +@deprecated(Deprecation("1.11.5", "Use :func:`scanpy.pl.dpt_timeseries` instead.")) +def timeseries(*args, **kwargs): + from ._utils import timeseries + + return timeseries(*args, **kwargs) + + +@deprecated(Deprecation("1.11.5", "Use :func:`scanpy.pl.dpt_timeseries` instead.")) +def timeseries_as_heatmap(*args, **kwargs): + from ._utils import timeseries_as_heatmap + + return timeseries_as_heatmap(*args, **kwargs) + + +@deprecated(Deprecation("1.11.5", "Use :func:`scanpy.pl.dpt_timeseries` instead.")) +def timeseries_subplot(*args, **kwargs): + from ._utils import timeseries_subplot + + return timeseries_subplot(*args, **kwargs) diff --git a/src/scanpy/plotting/_preprocessing.py b/src/scanpy/plotting/_preprocessing.py index 15055a0184..d59a236ba3 100644 --- a/src/scanpy/plotting/_preprocessing.py +++ b/src/scanpy/plotting/_preprocessing.py @@ -5,8 +5,9 @@ from anndata import AnnData from matplotlib import pyplot as plt from matplotlib import rcParams +from scverse_misc import Deprecation, deprecated -from .._compat import deprecated, old_positionals +from .._compat import old_positionals from .._settings import settings from ._utils import savefig_or_show @@ -126,7 +127,7 @@ def highly_variable_genes( # noqa: PLR0912 # backwards compat -@deprecated("Use sc.pl.highly_variable_genes instead") +@deprecated(Deprecation("1.3.6", "Use sc.pl.highly_variable_genes instead")) @old_positionals("log", "show", "save") def filter_genes_dispersion( result: np.recarray, diff --git a/src/scanpy/plotting/_tools/scatterplots.py b/src/scanpy/plotting/_tools/scatterplots.py index 7b1efaba22..6c9812de51 100644 --- a/src/scanpy/plotting/_tools/scatterplots.py +++ b/src/scanpy/plotting/_tools/scatterplots.py @@ -15,9 +15,9 @@ from matplotlib import pyplot as plt from matplotlib.colors import Normalize from matplotlib.markers import MarkerStyle +from scverse_misc import Deprecation, deprecated from ... import logging as logg -from ..._compat import deprecated from ..._settings import settings from ..._utils import _doc_params, _empty, sanitize_anndata from ..._utils._doctests import doctest_internet @@ -945,7 +945,7 @@ def pca( return axs -@deprecated("Use `squidpy.pl.spatial_scatter` instead.") +@deprecated(Deprecation("1.11.0", "Use :func:`squidpy.pl.spatial_scatter` instead.")) @doctest_internet @_wraps_plot_scatter @_doc_params( @@ -975,9 +975,6 @@ def spatial( # noqa: PLR0913 ) -> Figure | Axes | list[Axes] | None: """Scatter plot in spatial coordinates. - .. deprecated:: 1.11.0 - Use :func:`squidpy.pl.spatial_scatter` instead. - This function allows overlaying data on top of images. Use the parameter `img_key` to see the image in the background And the parameter `library_id` to select the image. @@ -1017,11 +1014,11 @@ def spatial( # noqa: PLR0913 >>> import scanpy as sc >>> adata = sc.datasets.visium_sge("Targeted_Visium_Human_Glioblastoma_Pan_Cancer") - FutureWarning: Use `squidpy.datasets.visium` instead. + FutureWarning: The function visium_sge is deprecated and will be removed in the future. Use :func:`squidpy.datasets.visium` instead. adata = sc.datasets.visium_sge("Targeted_Visium_Human_Glioblastoma_Pan_Cancer") >>> sc.pp.calculate_qc_metrics(adata, inplace=True) >>> sc.pl.spatial(adata, color="log1p_n_genes_by_counts") - FutureWarning: Use `squidpy.pl.spatial_scatter` instead. + FutureWarning: The function spatial is deprecated and will be removed in the future. Use :func:`squidpy.pl.spatial_scatter` instead. sc.pl.spatial(adata, color="log1p_n_genes_by_counts") See Also diff --git a/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py b/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py index c1db3d654b..461e056c81 100644 --- a/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py +++ b/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py @@ -7,16 +7,32 @@ import pandas as pd from anndata import AnnData from fast_array_utils.stats import mean_var +from scverse_misc import Deprecation, deprecated from ... import logging as logg -from ..._compat import CSBase, deprecated, old_positionals, warn +from ..._compat import CSBase, old_positionals, warn from .._distributed import materialize_as_ndarray if TYPE_CHECKING: from typing import Literal -@deprecated("Use sc.pp.highly_variable_genes instead") +@deprecated( + Deprecation( + "1.3.6", + """\ +Use :func:`~scanpy.pp.highly_variable_genes` instead. +The new function is equivalent to the present function, except that + +* the new function always expects logarithmized data +* `subset=False` in the new function, it suffices to + merely annotate the genes, tools like `pp.pca` will + detect the annotation +* you can now call: `sc.pl.highly_variable_genes(adata)` +* `copy` is replaced by `inplace`\ +""", + ) +) @old_positionals( "flavor", "min_disp", @@ -45,18 +61,6 @@ def filter_genes_dispersion( # noqa: PLR0912, PLR0913, PLR0915 ) -> AnnData | np.recarray | None: """Extract highly variable genes :cite:p:`Satija2015,Zheng2017`. - .. deprecated:: 1.3.6 - - Use :func:`~scanpy.pp.highly_variable_genes` instead. - The new function is equivalent to the present function, except that - - * the new function always expects logarithmized data - * `subset=False` in the new function, it suffices to - merely annotate the genes, tools like `pp.pca` will - detect the annotation - * you can now call: `sc.pl.highly_variable_genes(adata)` - * `copy` is replaced by `inplace` - If trying out parameters, pass the data matrix instead of AnnData. Depending on `flavor`, this reproduces the R-implementations of Seurat diff --git a/src/scanpy/preprocessing/_simple.py b/src/scanpy/preprocessing/_simple.py index cdd197e30d..3723b3b6ed 100644 --- a/src/scanpy/preprocessing/_simple.py +++ b/src/scanpy/preprocessing/_simple.py @@ -17,10 +17,11 @@ from fast_array_utils.conv import to_dense from fast_array_utils.numba import njit from pandas.api.types import CategoricalDtype +from scverse_misc import Deprecation, deprecated from sklearn.utils import check_array, sparsefuncs from .. import logging as logg -from .._compat import CSBase, CSRBase, DaskArray, deprecated, old_positionals +from .._compat import CSBase, CSRBase, DaskArray, old_positionals from .._settings import settings as sett from .._utils import ( _resolve_axis, @@ -468,7 +469,21 @@ def sqrt( return x.sqrt() if isinstance(x, CSBase) else np.sqrt(x) -@deprecated("Use `sc.pp.normalize_total` instead.") +@deprecated( + Deprecation( + "1.3.7", + """\ +Use :func:`~scanpy.pp.normalize_total` instead. +The new function is equivalent to the present +function, except that + +* the new function doesn't filter cells based on `min_counts`, + use :func:`~scanpy.pp.filter_cells` if filtering is needed. +* some arguments were renamed +* `copy` is replaced by `inplace`\ +""", + ) +) @old_positionals( "counts_per_cell_after", "counts_per_cell", @@ -491,17 +506,6 @@ def normalize_per_cell( ) -> AnnData | np.ndarray | CSBase | None: """Normalize total counts per cell. - .. deprecated:: 1.3.7 - - Use :func:`~scanpy.pp.normalize_total` instead. - The new function is equivalent to the present - function, except that - - * the new function doesn't filter cells based on `min_counts`, - use :func:`~scanpy.pp.filter_cells` if filtering is needed. - * some arguments were renamed - * `copy` is replaced by `inplace` - Normalize each cell by total counts over all genes, so that every cell has the same total count after normalization. diff --git a/src/scanpy/readwrite.py b/src/scanpy/readwrite.py index c412edd671..f42809ebd1 100644 --- a/src/scanpy/readwrite.py +++ b/src/scanpy/readwrite.py @@ -15,9 +15,10 @@ from anndata import AnnData from matplotlib.image import imread from packaging.version import Version +from scverse_misc import Deprecation, deprecated from . import logging as logg -from ._compat import deprecated, old_positionals, pkg_version, warn +from ._compat import old_positionals, pkg_version, warn from ._settings import AnnDataFileFormat, settings from ._utils import _empty @@ -369,7 +370,7 @@ def _read_legacy_10x_h5(f: h5py.File, genome: str | None) -> AnnData: return adata -@deprecated("Use `squidpy.read.visium` instead.") +@deprecated(Deprecation("1.11.0", "Use :func:`squidpy.read.visium` instead.")) def read_visium( path: PathLike[str] | str, genome: str | None = None, @@ -381,9 +382,6 @@ def read_visium( ) -> AnnData: r"""Read 10x-Genomics-formatted visum dataset. - .. deprecated:: 1.11.0 - Use :func:`squidpy.read.visium` instead. - In addition to reading regular 10x output, this looks for the `spatial` folder and loads images, coordinates and scale factors. diff --git a/src/scanpy/tools/_louvain.py b/src/scanpy/tools/_louvain.py index c50d39ccef..1154201eae 100644 --- a/src/scanpy/tools/_louvain.py +++ b/src/scanpy/tools/_louvain.py @@ -7,10 +7,11 @@ import pandas as pd from natsort import natsorted from packaging.version import Version +from scverse_misc import Deprecation, deprecated from .. import _utils from .. import logging as logg -from .._compat import deprecated, old_positionals, pkg_version, warn +from .._compat import old_positionals, pkg_version, warn from .._utils import _choose_graph, _doc_params, dematrix from ._docs import ( doc_adata, @@ -53,7 +54,7 @@ "obsp", "copy", ) -@deprecated("Use `scanpy.tl.leiden` instead") +@deprecated(Deprecation("1.12.0", "Use :func:`scanpy.tl.leiden` instead.")) @_doc_params( doc_adata=doc_adata, random_state=doc_random_state, @@ -81,9 +82,6 @@ def louvain( # noqa: PLR0912, PLR0913, PLR0915 ) -> AnnData | None: """Cluster cells into subgroups :cite:p:`Blondel2008,Levine2015,Traag2017`. - .. deprecated:: 1.12.0 - Use :func:`scanpy.tl.leiden` instead. - Cluster cells using the Louvain algorithm :cite:p:`Blondel2008` in the implementation of :cite:t:`Traag2017`. The Louvain algorithm was proposed for single-cell analysis by :cite:t:`Levine2015`. diff --git a/tests/notebooks/test_pbmc3k.py b/tests/notebooks/test_pbmc3k.py index afaac6a4bf..36b889d08b 100644 --- a/tests/notebooks/test_pbmc3k.py +++ b/tests/notebooks/test_pbmc3k.py @@ -79,7 +79,7 @@ def test_pbmc3k(subtests: pytest.Subtests, image_comparer) -> None: # noqa: PLR with pytest.warns(FutureWarning, match=r"sc\.pp\.normalize_total"): sc.pp.normalize_per_cell(adata, counts_per_cell_after=1e4) - with pytest.warns(FutureWarning, match=r"sc\.pp\.highly_variable_genes"): + with pytest.warns(FutureWarning, match=r"pp\.highly_variable_genes"): filter_result = sc.pp.filter_genes_dispersion( adata.X, min_mean=0.0125, @@ -88,7 +88,7 @@ def test_pbmc3k(subtests: pytest.Subtests, image_comparer) -> None: # noqa: PLR ) with subtests.test("filter_genes_dispersion"): - with pytest.warns(FutureWarning, match=r"sc\.pl\.highly_variable_genes"): + with pytest.warns(FutureWarning, match=r"pl\.highly_variable_genes"): sc.pl.filter_genes_dispersion(filter_result, show=False) save_and_compare_images("filter_genes_dispersion") diff --git a/tests/test_datasets.py b/tests/test_datasets.py index 38a2d4a1b8..48656d1349 100644 --- a/tests/test_datasets.py +++ b/tests/test_datasets.py @@ -112,7 +112,7 @@ def test_pbmc68k_reduced(): sc.datasets.pbmc68k_reduced() -@pytest.mark.filterwarnings("ignore:Use `squidpy.*` instead:FutureWarning") +@pytest.mark.filterwarnings("ignore:.*Use .*`squidpy.*` instead:FutureWarning") @pytest.mark.internet def test_visium_datasets(): """Tests that reading/ downloading works and is does not have global effects.""" @@ -123,7 +123,7 @@ def test_visium_datasets(): assert_adata_equal(hheart, hheart_again) -@pytest.mark.filterwarnings("ignore:Use `squidpy.*` instead:FutureWarning") +@pytest.mark.filterwarnings("ignore:.*Use .*`squidpy.*` instead:FutureWarning") @pytest.mark.internet def test_visium_datasets_dir_change(tmp_path: Path): """Test that changing the dataset dir doesn't break reading.""" @@ -135,7 +135,7 @@ def test_visium_datasets_dir_change(tmp_path: Path): assert_adata_equal(mbrain, mbrain_again) -@pytest.mark.filterwarnings("ignore:Use `squidpy.*` instead:FutureWarning") +@pytest.mark.filterwarnings("ignore:.*Use .*`squidpy.*` instead:FutureWarning") @pytest.mark.internet def test_visium_datasets_images(): """Test that image download works and is does not have global effects.""" diff --git a/tests/test_highly_variable_genes.py b/tests/test_highly_variable_genes.py index 0ee2912d37..d232b4d5cc 100644 --- a/tests/test_highly_variable_genes.py +++ b/tests/test_highly_variable_genes.py @@ -403,7 +403,7 @@ def test_compare_to_upstream( sc.pp.log1p(pbmc) sc.pp.highly_variable_genes(pbmc, flavor=flavor, **params, inplace=True) elif func == "fgd": - with pytest.warns(FutureWarning, match=r"sc\.pp\.highly_variable_genes"): # noqa: PT031 + with pytest.warns(FutureWarning, match=r"pp\.highly_variable_genes"): # noqa: PT031 # https://github.com/pandas-dev/pandas/issues/61928 warnings.filterwarnings( "ignore", r"invalid value encountered in cast", RuntimeWarning diff --git a/tests/test_plotting_embedded/test_embeddings.py b/tests/test_plotting_embedded/test_embeddings.py index e8d4331218..c5a51d3567 100644 --- a/tests/test_plotting_embedded/test_embeddings.py +++ b/tests/test_plotting_embedded/test_embeddings.py @@ -49,7 +49,7 @@ def plotfunc(request): @wraps(request.param) def f(adata, **kwargs): - with pytest.warns(FutureWarning, match=r"Use `squidpy.*` instead"): + with pytest.warns(FutureWarning, match=r".*Use .*`squidpy.*` instead"): return sc.pl.spatial(adata, **kwargs) else: diff --git a/tests/test_plotting_embedded/test_spatial.py b/tests/test_plotting_embedded/test_spatial.py index 87138451de..aaff0dfc1a 100644 --- a/tests/test_plotting_embedded/test_spatial.py +++ b/tests/test_plotting_embedded/test_spatial.py @@ -16,7 +16,7 @@ pytestmark = [ - pytest.mark.filterwarnings("ignore:Use `squidpy.*` instead:FutureWarning") + pytest.mark.filterwarnings("ignore:.*Use .*`squidpy.*` instead:FutureWarning") ] diff --git a/tests/test_preprocessing.py b/tests/test_preprocessing.py index 82087ed6fe..7a9f926ee7 100644 --- a/tests/test_preprocessing.py +++ b/tests/test_preprocessing.py @@ -382,9 +382,9 @@ def test_recipe_plotting() -> None: sc.settings.autoshow = False adata = AnnData(np.random.randint(0, 1000, (1000, 1000))) # These shouldn't throw an error - with pytest.warns(FutureWarning, match=r"sc\.p[pl]\.highly_variable_genes"): + with pytest.warns(FutureWarning, match=r"p[pl]\.highly_variable_genes"): sc.pp.recipe_seurat(adata.copy(), plot=True) - with pytest.warns(FutureWarning, match=r"sc\.p[pl]\.highly_variable_genes"): + with pytest.warns(FutureWarning, match=r"p[pl]\.highly_variable_genes"): sc.pp.recipe_zheng17(adata.copy(), plot=True) diff --git a/tests/test_read_10x.py b/tests/test_read_10x.py index 811896a347..b0599e4018 100644 --- a/tests/test_read_10x.py +++ b/tests/test_read_10x.py @@ -174,7 +174,7 @@ def visium_pth(request, tmp_path) -> Path: pytest.fail("add branch for new visium version") -@pytest.mark.filterwarnings("ignore:Use `squidpy.*` instead:FutureWarning") +@pytest.mark.filterwarnings("ignore:.*Use .*`squidpy.*` instead:FutureWarning") def test_read_visium_counts(visium_pth): """Test checking that read_visium reads the right genome.""" spec_genome_v3 = sc.read_visium(visium_pth, genome="GRCh38")