Skip to content

Commit f11b6ba

Browse files
committed
Use deprecation decorator
1 parent 751eafa commit f11b6ba

File tree

5 files changed

+39
-23
lines changed

5 files changed

+39
-23
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ dependencies = [
6666
"packaging>=21.3",
6767
"session-info",
6868
"legacy-api-wrap>=1.4", # for positional API deprecations
69+
"typing-extensions; python_version < '3.13'",
6970
]
7071
dynamic = ["version"]
7172

src/scanpy/_compat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class ZappyArray:
4848
"fullname",
4949
"pkg_metadata",
5050
"pkg_version",
51+
"old_positionals",
52+
"deprecated",
53+
"njit",
54+
"_numba_threading_layer",
5155
]
5256

5357

@@ -102,6 +106,15 @@ def old_positionals(*old_positionals: str):
102106
return lambda func: func
103107

104108

109+
if sys.version_info >= (3, 13):
110+
from warnings import deprecated as _deprecated
111+
else:
112+
from typing_extensions import deprecated as _deprecated
113+
114+
115+
deprecated = partial(_deprecated, category=FutureWarning)
116+
117+
105118
@overload
106119
def njit(fn: Callable[P, R], /) -> Callable[P, R]: ...
107120
@overload

src/scanpy/plotting/_preprocessing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from matplotlib import pyplot as plt
77
from matplotlib import rcParams
88

9-
from .._compat import old_positionals
9+
from .._compat import deprecated, old_positionals
1010
from .._settings import settings
1111
from . import _utils
1212

@@ -103,6 +103,7 @@ def highly_variable_genes(
103103

104104

105105
# backwards compat
106+
@deprecated("Use sc.pl.highly_variable_genes instead")
106107
@old_positionals("log", "show", "save")
107108
def filter_genes_dispersion(
108109
result: np.recarray,

src/scanpy/preprocessing/_deprecated/highly_variable_genes.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from scipy.sparse import issparse
1010

1111
from ... import logging as logg
12-
from ..._compat import old_positionals
12+
from ..._compat import deprecated, old_positionals
1313
from .._distributed import materialize_as_ndarray
1414
from .._utils import _get_mean_var
1515

@@ -19,6 +19,7 @@
1919
from scipy.sparse import spmatrix
2020

2121

22+
@deprecated("Use sc.pp.highly_variable_genes instead")
2223
@old_positionals(
2324
"flavor",
2425
"min_disp",
@@ -48,18 +49,17 @@ def filter_genes_dispersion(
4849
"""\
4950
Extract highly variable genes :cite:p:`Satija2015,Zheng2017`.
5051
51-
.. warning::
52-
.. deprecated:: 1.3.6
53-
Use :func:`~scanpy.pp.highly_variable_genes`
54-
instead. The new function is equivalent to the present
55-
function, except that
52+
.. deprecated:: 1.3.6
5653
57-
* the new function always expects logarithmized data
58-
* `subset=False` in the new function, it suffices to
59-
merely annotate the genes, tools like `pp.pca` will
60-
detect the annotation
61-
* you can now call: `sc.pl.highly_variable_genes(adata)`
62-
* `copy` is replaced by `inplace`
54+
Use :func:`~scanpy.pp.highly_variable_genes` instead.
55+
The new function is equivalent to the present function, except that
56+
57+
* the new function always expects logarithmized data
58+
* `subset=False` in the new function, it suffices to
59+
merely annotate the genes, tools like `pp.pca` will
60+
detect the annotation
61+
* you can now call: `sc.pl.highly_variable_genes(adata)`
62+
* `copy` is replaced by `inplace`
6363
6464
If trying out parameters, pass the data matrix instead of AnnData.
6565

src/scanpy/preprocessing/_simple.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from sklearn.utils import check_array, sparsefuncs
1919

2020
from .. import logging as logg
21-
from .._compat import njit, old_positionals
21+
from .._compat import deprecated, njit, old_positionals
2222
from .._settings import settings as sett
2323
from .._utils import (
2424
_check_array_function_arguments,
@@ -474,6 +474,7 @@ def sqrt(
474474
return X.sqrt()
475475

476476

477+
@deprecated("Use sc.pp.normalize_total instead")
477478
@old_positionals(
478479
"counts_per_cell_after",
479480
"counts_per_cell",
@@ -497,16 +498,16 @@ def normalize_per_cell(
497498
"""\
498499
Normalize total counts per cell.
499500
500-
.. warning::
501-
.. deprecated:: 1.3.7
502-
Use :func:`~scanpy.pp.normalize_total` instead.
503-
The new function is equivalent to the present
504-
function, except that
501+
.. deprecated:: 1.3.7
505502
506-
* the new function doesn't filter cells based on `min_counts`,
507-
use :func:`~scanpy.pp.filter_cells` if filtering is needed.
508-
* some arguments were renamed
509-
* `copy` is replaced by `inplace`
503+
Use :func:`~scanpy.pp.normalize_total` instead.
504+
The new function is equivalent to the present
505+
function, except that
506+
507+
* the new function doesn't filter cells based on `min_counts`,
508+
use :func:`~scanpy.pp.filter_cells` if filtering is needed.
509+
* some arguments were renamed
510+
* `copy` is replaced by `inplace`
510511
511512
Normalize each cell by total counts over all genes, so that every cell has
512513
the same total count after normalization.

0 commit comments

Comments
 (0)