diff --git a/docs/release-notes/3984.chore.md b/docs/release-notes/3984.chore.md new file mode 100644 index 0000000000..de4a4ddb9b --- /dev/null +++ b/docs/release-notes/3984.chore.md @@ -0,0 +1 @@ +Remove compatibility helper for passing parameters positionally {smaller}`P Angerer` diff --git a/pyproject.toml b/pyproject.toml index fd1c7b982a..b2704ff825 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,6 @@ dependencies = [ "fast-array-utils[accel,sparse]>=1.2.1", "h5py>=3.11", "joblib", - "legacy-api-wrap>=1.5", # for positional API deprecations "matplotlib>=3.9", "natsort", "networkx>=2.8.8", @@ -214,7 +213,6 @@ lint.pylint.max-args = 10 lint.pylint.max-positional-args = 5 [tool.ruff.lint.flake8-tidy-imports.banned-api] -"legacy_api_wrap.legacy_api".msg = "Use scanpy._compat.old_positionals instead" "numba.jit".msg = "Use `scanpy._compat.njit` instead" "numba.njit".msg = "Use `scanpy._compat.njit` instead" "numpy.bool".msg = "Use `np.bool_` instead for numpy>=1.24<2 compatibility" diff --git a/src/scanpy/_compat.py b/src/scanpy/_compat.py index 11b0704328..32b24a57fb 100644 --- a/src/scanpy/_compat.py +++ b/src/scanpy/_compat.py @@ -7,7 +7,6 @@ from pathlib import Path from typing import TYPE_CHECKING, Literal, cast, overload -import legacy_api_wrap from packaging.version import Version from scipy import sparse @@ -26,7 +25,6 @@ "deprecated", "fullname", "njit", - "old_positionals", "pkg_metadata", "pkg_version", "warn", @@ -79,17 +77,7 @@ def pkg_version(package: str) -> Version: # File prefixes for us and decorators we use -_FILE_PREFIXES: tuple[str, ...] = ( - str(Path(__file__).parent), - str(Path(legacy_api_wrap.__file__).parent), -) - - -old_positionals = partial( - legacy_api_wrap.legacy_api, # noqa: TID251 - category=FutureWarning, - skip_file_prefixes=_FILE_PREFIXES, -) +_FILE_PREFIXES: tuple[str, ...] = (str(Path(__file__).parent),) # we’re not using _FILE_PREFIXES here, diff --git a/src/scanpy/_settings/__init__.py b/src/scanpy/_settings/__init__.py index 2c43b2d74c..4b57c5e0a9 100644 --- a/src/scanpy/_settings/__init__.py +++ b/src/scanpy/_settings/__init__.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Literal, get_args from .. import logging -from .._compat import deprecated, old_positionals +from .._compat import deprecated from .._singleton import SingletonMeta, documenting from ..logging import _RootLogger, _set_log_file, _set_log_level from .verbosity import Verbosity @@ -334,20 +334,6 @@ def categories_to_ignore(cls, categories_to_ignore: Iterable[str]) -> None: def set_figure_params(cls, *args, **kwargs) -> None: cls._set_figure_params(*args, **kwargs) - @old_positionals( - "scanpy", - "dpi", - "dpi_save", - "frameon", - "vector_friendly", - "fontsize", - "figsize", - "color_map", - "format", - "facecolor", - "transparent", - "ipython_format", - ) def _set_figure_params( # noqa: PLR0913 cls, *, diff --git a/src/scanpy/datasets/_datasets.py b/src/scanpy/datasets/_datasets.py index d6221fe8d2..1a81939301 100644 --- a/src/scanpy/datasets/_datasets.py +++ b/src/scanpy/datasets/_datasets.py @@ -9,7 +9,7 @@ from anndata import AnnData, OldFormatWarning from .. import _utils -from .._compat import deprecated, old_positionals +from .._compat import deprecated from .._settings import settings from .._utils._doctests import doctest_internet, doctest_needs from ..readwrite import read, read_h5ad, read_visium @@ -54,9 +54,6 @@ HERE = Path(__file__).parent -@old_positionals( - "n_variables", "n_centers", "cluster_std", "n_observations", "random_state" -) def blobs( *, n_variables: int = 11, diff --git a/src/scanpy/external/exporting.py b/src/scanpy/external/exporting.py index 5c8db72580..e936060caa 100644 --- a/src/scanpy/external/exporting.py +++ b/src/scanpy/external/exporting.py @@ -14,7 +14,6 @@ from fast_array_utils.stats import mean_var from pandas.api.types import CategoricalDtype -from .._compat import old_positionals from .._utils import NeighborsView if TYPE_CHECKING: @@ -25,14 +24,6 @@ __all__ = ["cellbrowser", "spring_project"] -@old_positionals( - "subplot_name", - "cell_groupings", - "custom_color_tracks", - "total_counts_key", - "neighbors_key", - "overwrite", -) def spring_project( # noqa: PLR0912, PLR0915 adata: AnnData, project_dir: Path | str, @@ -472,16 +463,6 @@ def _export_paga_to_spring(adata, paga_coords, outpath) -> None: Path(outpath).write_text(json.dumps(paga_data, indent=4)) -@old_positionals( - "embedding_keys", - "annot_keys", - "cluster_field", - "nb_marker", - "skip_matrix", - "html_dir", - "port", - "do_debug", -) def cellbrowser( # noqa: PLR0913 adata: AnnData, data_dir: Path | str, diff --git a/src/scanpy/external/pl.py b/src/scanpy/external/pl.py index 73d63a2bff..365fdb57b0 100644 --- a/src/scanpy/external/pl.py +++ b/src/scanpy/external/pl.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -from .._compat import deprecated, old_positionals +from .._compat import deprecated from .._utils import _doc_params from .._utils._doctests import doctest_needs from ..plotting import _scrublet, _utils, embedding @@ -162,7 +162,6 @@ def harmony_timeseries( return axes -@old_positionals("c", "cmap", "linewidth", "edgecolor", "axes", "colorbar", "s") def sam( adata: AnnData, projection: str | np.ndarray = "X_umap", @@ -257,17 +256,6 @@ def sam( return axes -@old_positionals( - "no_bins", - "smoothing_factor", - "min_delta", - "show_variance", - "figsize", - "return_fig", - "show", - "save", - "ax", -) @_doc_params(show_save_ax=doc_show_save_ax) def wishbone_marker_trajectory( # noqa: PLR0913 adata: AnnData, diff --git a/src/scanpy/external/pp/_bbknn.py b/src/scanpy/external/pp/_bbknn.py index 1621153fc5..0a984fb59f 100644 --- a/src/scanpy/external/pp/_bbknn.py +++ b/src/scanpy/external/pp/_bbknn.py @@ -2,7 +2,6 @@ from typing import TYPE_CHECKING -from ..._compat import old_positionals from ..._utils._doctests import doctest_needs if TYPE_CHECKING: @@ -12,7 +11,6 @@ from sklearn.metrics import DistanceMetric -@old_positionals("batch_key", "use_rep", "approx", "use_annoy", "metric", "copy") @doctest_needs("bbknn") def bbknn( # noqa: PLR0913 adata: AnnData, diff --git a/src/scanpy/external/pp/_dca.py b/src/scanpy/external/pp/_dca.py index 12d93c2c53..3df38ea36b 100644 --- a/src/scanpy/external/pp/_dca.py +++ b/src/scanpy/external/pp/_dca.py @@ -3,8 +3,6 @@ from types import MappingProxyType from typing import TYPE_CHECKING -from ..._compat import old_positionals - if TYPE_CHECKING: from collections.abc import Mapping, Sequence from typing import Any, Literal @@ -16,31 +14,6 @@ type _AEType = Literal["zinb-conddisp", "zinb", "nb-conddisp", "nb"] -@old_positionals( - "ae_type", - "normalize_per_cell", - "scale", - "log1p", - "hidden_size", - "hidden_dropout", - "batchnorm", - "activation", - "init", - "network_kwds", - "epochs", - "reduce_lr", - "early_stop", - "batch_size", - "optimizer", - "random_state", - "threads", - "learning_rate", - "verbose", - "training_kwds", - "return_model", - "return_info", - "copy", -) def dca( # noqa: PLR0913 adata: AnnData, mode: Literal["denoise", "latent"] = "denoise", diff --git a/src/scanpy/external/pp/_harmony_integrate.py b/src/scanpy/external/pp/_harmony_integrate.py index d4e9982fef..045fcbe25a 100644 --- a/src/scanpy/external/pp/_harmony_integrate.py +++ b/src/scanpy/external/pp/_harmony_integrate.py @@ -6,7 +6,6 @@ import numpy as np -from ..._compat import old_positionals from ..._utils._doctests import doctest_needs if TYPE_CHECKING: @@ -15,7 +14,6 @@ from anndata import AnnData -@old_positionals("basis", "adjusted_basis") @doctest_needs("harmonypy") def harmony_integrate( adata: AnnData, diff --git a/src/scanpy/external/pp/_hashsolo.py b/src/scanpy/external/pp/_hashsolo.py index 8713c23956..210ffa05e8 100644 --- a/src/scanpy/external/pp/_hashsolo.py +++ b/src/scanpy/external/pp/_hashsolo.py @@ -37,7 +37,6 @@ import pandas as pd from scipy.stats import norm -from ..._compat import old_positionals from ..._utils import check_nonnegative_integers from ..._utils._doctests import doctest_skip @@ -292,9 +291,6 @@ def _calculate_bayes_rule( } -@old_positionals( - "priors", "pre_existing_clusters", "number_of_noise_barcodes", "inplace" -) @doctest_skip("Illustrative but not runnable doctest code") def hashsolo( adata: AnnData, diff --git a/src/scanpy/external/pp/_scanorama_integrate.py b/src/scanpy/external/pp/_scanorama_integrate.py index 1809491570..24f35ef954 100644 --- a/src/scanpy/external/pp/_scanorama_integrate.py +++ b/src/scanpy/external/pp/_scanorama_integrate.py @@ -6,16 +6,12 @@ import numpy as np -from ..._compat import old_positionals from ..._utils._doctests import doctest_needs if TYPE_CHECKING: from anndata import AnnData -@old_positionals( - "basis", "adjusted_basis", "knn", "sigma", "approx", "alpha", "batch_size" -) @doctest_needs("scanorama") def scanorama_integrate( adata: AnnData, diff --git a/src/scanpy/external/tl/_harmony_timeseries.py b/src/scanpy/external/tl/_harmony_timeseries.py index 2e2e3e6e02..95f0565fad 100644 --- a/src/scanpy/external/tl/_harmony_timeseries.py +++ b/src/scanpy/external/tl/_harmony_timeseries.py @@ -8,14 +8,12 @@ import pandas as pd from ... import logging as logg -from ..._compat import old_positionals from ..._utils._doctests import doctest_needs if TYPE_CHECKING: from anndata import AnnData -@old_positionals("n_neighbors", "n_components", "n_jobs", "copy") @doctest_needs("harmony") def harmony_timeseries( adata: AnnData, diff --git a/src/scanpy/external/tl/_palantir.py b/src/scanpy/external/tl/_palantir.py index 5fb46bb09d..0526ab9b58 100644 --- a/src/scanpy/external/tl/_palantir.py +++ b/src/scanpy/external/tl/_palantir.py @@ -7,24 +7,12 @@ import pandas as pd from ... import logging as logg -from ..._compat import old_positionals from ..._utils._doctests import doctest_needs if TYPE_CHECKING: from anndata import AnnData -@old_positionals( - "n_components", - "knn", - "alpha", - "use_adjacency_matrix", - "distances_key", - "n_eigs", - "impute_data", - "n_steps", - "copy", -) @doctest_needs("palantir") def palantir( adata: AnnData, @@ -254,16 +242,6 @@ def palantir( return adata if copy else None -@old_positionals( - "ms_data", - "terminal_states", - "knn", - "num_waypoints", - "n_jobs", - "scale_components", - "use_early_cell_as_start", - "max_iterations", -) def palantir_results( adata: AnnData, early_cell: str, diff --git a/src/scanpy/external/tl/_phate.py b/src/scanpy/external/tl/_phate.py index 9986260709..54d12643cf 100644 --- a/src/scanpy/external/tl/_phate.py +++ b/src/scanpy/external/tl/_phate.py @@ -5,7 +5,6 @@ from typing import TYPE_CHECKING from ... import logging as logg -from ..._compat import old_positionals from ..._settings import settings from ..._utils._doctests import doctest_needs @@ -17,21 +16,6 @@ from ..._utils.random import _LegacyRandom -@old_positionals( - "k", - "a", - "n_landmark", - "t", - "gamma", - "n_pca", - "knn_dist", - "mds_dist", - "mds", - "n_jobs", - "random_state", - "verbose", - "copy", -) @doctest_needs("phate") def phate( # noqa: PLR0913 adata: AnnData, diff --git a/src/scanpy/external/tl/_phenograph.py b/src/scanpy/external/tl/_phenograph.py index 4ccb9df105..655c9bdf31 100644 --- a/src/scanpy/external/tl/_phenograph.py +++ b/src/scanpy/external/tl/_phenograph.py @@ -9,8 +9,7 @@ from packaging.version import Version from ... import logging as logg -from ..._compat import old_positionals, pkg_version -from ..._utils import renamed_arg +from ..._compat import pkg_version from ..._utils._doctests import doctest_needs if TYPE_CHECKING: @@ -22,25 +21,6 @@ from ...tools._leiden import MutableVertexPartition -@renamed_arg("adata", "data", pos_0=True) -@old_positionals( - "k", - "directed", - "prune", - "min_cluster_size", - "jaccard", - "primary_metric", - "n_jobs", - "q_tol", - "louvain_time_limit", - "nn_method", - "partition_type", - "resolution_parameter", - "n_iterations", - "use_weights", - "seed", - "copy", -) @doctest_needs("phenograph") def phenograph( # noqa: PLR0913 data: AnnData | np.ndarray | SpBase, diff --git a/src/scanpy/external/tl/_sam.py b/src/scanpy/external/tl/_sam.py index eed58ba6a0..77b0c7dc73 100644 --- a/src/scanpy/external/tl/_sam.py +++ b/src/scanpy/external/tl/_sam.py @@ -5,7 +5,6 @@ from typing import TYPE_CHECKING from ... import logging as logg -from ..._compat import old_positionals from ..._utils._doctests import doctest_needs if TYPE_CHECKING: @@ -15,20 +14,6 @@ from samalg import SAM -@old_positionals( - "max_iter", - "num_norm_avg", - "k", - "distance", - "standardization", - "weight_pcs", - "sparse_pca", - "n_pcs", - "n_genes", - "projection", - "inplace", - "verbose", -) @doctest_needs("samalg") def sam( # noqa: PLR0913 adata: AnnData, diff --git a/src/scanpy/external/tl/_trimap.py b/src/scanpy/external/tl/_trimap.py index 5b3d9859ed..8ccd08f1f3 100644 --- a/src/scanpy/external/tl/_trimap.py +++ b/src/scanpy/external/tl/_trimap.py @@ -5,7 +5,7 @@ from typing import TYPE_CHECKING from ... import logging as logg -from ..._compat import CSBase, old_positionals +from ..._compat import CSBase from ..._settings import settings from ..._utils._doctests import doctest_needs @@ -15,17 +15,6 @@ from anndata import AnnData -@old_positionals( - "n_inliers", - "n_outliers", - "n_random", - "metric", - "weight_adj", - "lr", - "n_iters", - "verbose", - "copy", -) @doctest_needs("trimap") def trimap( # noqa: PLR0913 adata: AnnData, diff --git a/src/scanpy/external/tl/_wishbone.py b/src/scanpy/external/tl/_wishbone.py index fe18b65efc..20995e1b68 100644 --- a/src/scanpy/external/tl/_wishbone.py +++ b/src/scanpy/external/tl/_wishbone.py @@ -7,7 +7,6 @@ import pandas as pd from ... import logging -from ..._compat import old_positionals from ..._utils._doctests import doctest_needs if TYPE_CHECKING: @@ -16,7 +15,6 @@ from anndata import AnnData -@old_positionals("branch", "k", "components", "num_waypoints") @doctest_needs("wishbone") def wishbone( adata: AnnData, diff --git a/src/scanpy/neighbors/__init__.py b/src/scanpy/neighbors/__init__.py index 3efb392a1d..87314140d5 100644 --- a/src/scanpy/neighbors/__init__.py +++ b/src/scanpy/neighbors/__init__.py @@ -15,7 +15,7 @@ from .. import _utils from .. import logging as logg -from .._compat import CSBase, CSRBase, SpBase, old_positionals, warn +from .._compat import CSBase, CSRBase, SpBase, warn from .._settings import settings from .._utils import NeighborsView, _doc_params, get_literal_vals from . import _connectivity @@ -416,14 +416,13 @@ class Neighbors: """ - @old_positionals("n_dcs", "neighbors_key") def __init__( # noqa: PLR0912, PLR0915 self, adata: AnnData, *, n_dcs: int | None = None, neighbors_key: str | None = None, - ): + ) -> None: self._adata = adata self._init_iroot() # use the graph in adata @@ -802,8 +801,7 @@ def _handle_transformer( # else `transformer` is probably an instance return conn_method, transformer, shortcut - @old_positionals("density_normalize") - def compute_transitions(self, *, density_normalize: bool = True): + def compute_transitions(self, *, density_normalize: bool = True) -> None: """Compute transition matrix. Parameters diff --git a/src/scanpy/plotting/_anndata.py b/src/scanpy/plotting/_anndata.py index 97d82ab7c1..dae739b9f9 100755 --- a/src/scanpy/plotting/_anndata.py +++ b/src/scanpy/plotting/_anndata.py @@ -17,7 +17,7 @@ from .. import get from .. import logging as logg -from .._compat import CSBase, old_positionals +from .._compat import CSBase from .._settings import settings from .._utils import ( _doc_params, @@ -95,23 +95,6 @@ def validate( return None if len(labels) == 0 else cls(labels, positions) -@old_positionals( - "color", - "use_raw", - "layers", - "sort_order", - "alpha", - "basis", - "groups", - "components", - "projection", - "legend_loc", - "legend_fontsize", - "legend_fontweight", - "legend_fontoutline", - "color_map", - # 17 positionals are enough for backwards compatibility -) @_doc_params(scatter_temp=doc_scatter_basic, show_save_ax=doc_show_save_ax) def scatter( # noqa: PLR0913 adata: AnnData, @@ -577,16 +560,6 @@ def add_centroid(centroids, name, xy, mask) -> None: return axs[0] -@old_positionals( - "dictionary", - "indices", - "labels", - "color", - "n_points", - "log", - "include_lowest", - "show", -) def ranking( # noqa: PLR0912, PLR0913 adata: AnnData, attr: Literal["var", "obs", "uns", "varm", "obsm"], @@ -704,23 +677,6 @@ def ranking( # noqa: PLR0912, PLR0913 return gs -@old_positionals( - "log", - "use_raw", - "stripplot", - "jitter", - "size", - "layer", - "scale", - "order", - "multi_panel", - "xlabel", - "ylabel", - "rotation", - "show", - "save", - "ax", -) @_doc_params(show_save_ax=doc_show_save_ax) def violin( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, @@ -989,7 +945,6 @@ def violin( # noqa: PLR0912, PLR0913, PLR0915 return axs -@old_positionals("use_raw", "show", "save") @_doc_params(show_save_ax=doc_show_save_ax) def clustermap( adata: AnnData, @@ -1068,27 +1023,6 @@ def clustermap( return g -@old_positionals( - "use_raw", - "log", - "num_categories", - "dendrogram", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "var_group_rotation", - "layer", - "standard_scale", - "swap_axes", - "show_gene_labels", - "show", - "save", - "figsize", - "vmin", - "vmax", - "vcenter", - "norm", -) @_doc_params( vminmax=doc_vboundnorm, show_save_ax=doc_show_save_ax, @@ -1477,18 +1411,6 @@ def heatmap( # noqa: PLR0912, PLR0913, PLR0915 return return_ax_dict -@old_positionals( - "use_raw", - "log", - "dendrogram", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "layer", - "show", - "save", - "figsize", -) @_doc_params(show_save_ax=doc_show_save_ax, common_plot_args=doc_common_plot_args) def tracksplot( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, @@ -1815,18 +1737,6 @@ def dendrogram( return ax -@old_positionals( - "show_correlation_numbers", - "dendrogram", - "figsize", - "show", - "save", - "ax", - "vmin", - "vmax", - "vcenter", - "norm", -) @_doc_params(show_save_ax=doc_show_save_ax, vminmax=doc_vboundnorm) def correlation_matrix( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, diff --git a/src/scanpy/plotting/_baseplot_class.py b/src/scanpy/plotting/_baseplot_class.py index 20ecb30809..31c5220570 100644 --- a/src/scanpy/plotting/_baseplot_class.py +++ b/src/scanpy/plotting/_baseplot_class.py @@ -10,7 +10,7 @@ from matplotlib import pyplot as plt from .. import logging as logg -from .._compat import old_positionals, warn +from .._compat import warn from .._utils import _empty from ._anndata import ( VarGroups, @@ -92,24 +92,6 @@ class BasePlot: var_groups: VarGroups | None - @old_positionals( - "use_raw", - "log", - "num_categories", - "categories_order", - "title", - "figsize", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "var_group_rotation", - "layer", - "ax", - "vmin", - "vmax", - "vcenter", - "norm", - ) def __init__( # noqa: PLR0913 self, adata: AnnData, @@ -209,7 +191,6 @@ def __init__( # noqa: PLR0913 self.ax_dict = None self.ax = ax - @old_positionals("swap_axes") def swap_axes(self, *, swap_axes: bool | None = True) -> Self: """Plot a transposed image. @@ -236,7 +217,6 @@ def swap_axes(self, *, swap_axes: bool | None = True) -> Self: self.are_axes_swapped = swap_axes return self - @old_positionals("show", "dendrogram_key", "size") def add_dendrogram( self, *, @@ -325,7 +305,6 @@ def add_dendrogram( } return self - @old_positionals("show", "sort", "size", "color") def add_totals( self, *, @@ -409,7 +388,6 @@ def add_totals( } return self - @old_positionals("cmap") def style(self, *, cmap: Colormap | str | None | Empty = _empty) -> Self: r"""Set visual style parameters. @@ -428,7 +406,6 @@ def style(self, *, cmap: Colormap | str | None | Empty = _empty) -> Self: self.cmap = cmap return self - @old_positionals("show", "title", "width") def legend( self, *, @@ -808,7 +785,6 @@ def make_figure(self) -> None: # noqa: PLR0912, PLR0915 self.ax_dict = return_ax_dict - @old_positionals("return_axes") def show(self, *, return_axes: bool | None = None) -> dict[str, Axes] | None: """Show the figure. diff --git a/src/scanpy/plotting/_dotplot.py b/src/scanpy/plotting/_dotplot.py index b903e781f3..98ffc7d736 100644 --- a/src/scanpy/plotting/_dotplot.py +++ b/src/scanpy/plotting/_dotplot.py @@ -6,7 +6,7 @@ from matplotlib import colormaps from .. import logging as logg -from .._compat import old_positionals, warn +from .._compat import warn from .._settings import settings from .._utils import _doc_params, _empty from ._baseplot_class import BasePlot, doc_common_groupby_plot_args @@ -113,29 +113,6 @@ class DotPlot(BasePlot): DEFAULT_PLOT_X_PADDING = 0.8 # a unit is the distance between two x-axis ticks DEFAULT_PLOT_Y_PADDING = 1.0 # a unit is the distance between two y-axis ticks - @old_positionals( - "use_raw", - "log", - "num_categories", - "categories_order", - "title", - "figsize", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "var_group_rotation", - "layer", - "expression_cutoff", - "mean_only_expressed", - "standard_scale", - "dot_color_df", - "dot_size_df", - "ax", - "vmin", - "vmax", - "vcenter", - "norm", - ) def __init__( # noqa: PLR0913 self, adata: AnnData, @@ -333,20 +310,6 @@ def _prepare_dot_data( return dot_color_df, dot_size_df - @old_positionals( - "cmap", - "color_on", - "dot_max", - "dot_min", - "smallest_dot", - "largest_dot", - "dot_edge_color", - "dot_edge_lw", - "size_exponent", - "grid", - "x_padding", - "y_padding", - ) def style( # noqa: PLR0913 self, *, @@ -460,14 +423,6 @@ def style( # noqa: PLR0913 return self - @old_positionals( - "show", - "show_size_legend", - "show_colorbar", - "size_title", - "colorbar_title", - "width", - ) def legend( self, *, @@ -990,22 +945,6 @@ def _dotplot( # noqa: PLR0912, PLR0913, PLR0915 return normalize, dot_min, dot_max -@old_positionals( - "use_raw", - "log", - "num_categories", - "expression_cutoff", - "mean_only_expressed", - "cmap", - "dot_max", - "dot_min", - "standard_scale", - "smallest_dot", - "title", - "colorbar_title", - "size_title", - # No need to have backwards compat for > 16 positional parameters -) @_doc_params( show_save_ax=doc_show_save_ax, common_plot_args=doc_common_plot_args, diff --git a/src/scanpy/plotting/_matrixplot.py b/src/scanpy/plotting/_matrixplot.py index e803bdc1eb..76c325d9be 100644 --- a/src/scanpy/plotting/_matrixplot.py +++ b/src/scanpy/plotting/_matrixplot.py @@ -6,7 +6,6 @@ from matplotlib import colormaps, rcParams from .. import logging as logg -from .._compat import old_positionals from .._settings import settings from .._utils import _doc_params, _empty from ._baseplot_class import BasePlot, doc_common_groupby_plot_args @@ -96,26 +95,6 @@ class MatrixPlot(BasePlot): DEFAULT_EDGE_COLOR = "gray" DEFAULT_EDGE_LW = 0.1 - @old_positionals( - "use_raw", - "log", - "num_categories", - "categories_order", - "title", - "figsize", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "var_group_rotation", - "layer", - "standard_scale", - "ax", - "values_df", - "vmin", - "vmax", - "vcenter", - "norm", - ) def __init__( # noqa: PLR0913 self, adata: AnnData, @@ -312,23 +291,6 @@ def _mainplot(self, ax: Axes): return normalize -@old_positionals( - "use_raw", - "log", - "num_categories", - "figsize", - "dendrogram", - "title", - "cmap", - "colorbar_title", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "var_group_rotation", - "layer", - "standard_scale", - # 17 positionals are enough for backwards compatibility -) @_doc_params( show_save_ax=doc_show_save_ax, common_plot_args=doc_common_plot_args, diff --git a/src/scanpy/plotting/_preprocessing.py b/src/scanpy/plotting/_preprocessing.py index 60356757e6..577cde2d26 100644 --- a/src/scanpy/plotting/_preprocessing.py +++ b/src/scanpy/plotting/_preprocessing.py @@ -6,7 +6,7 @@ from matplotlib import pyplot as plt from matplotlib import rcParams -from .._compat import deprecated, old_positionals +from .._compat import deprecated from .._settings import settings from ._utils import savefig_or_show @@ -15,7 +15,6 @@ # -------------------------------------------------------------------------------- -@old_positionals("log", "show", "save", "highly_variable_genes") def highly_variable_genes( # noqa: PLR0912 adata_or_result: AnnData | pd.DataFrame | np.recarray, *, @@ -106,7 +105,6 @@ def highly_variable_genes( # noqa: PLR0912 # backwards compat @deprecated("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/_qc.py b/src/scanpy/plotting/_qc.py index 439b22a88d..e316c11a82 100644 --- a/src/scanpy/plotting/_qc.py +++ b/src/scanpy/plotting/_qc.py @@ -6,7 +6,7 @@ import pandas as pd from matplotlib import pyplot as plt -from .._compat import CSBase, old_positionals +from .._compat import CSBase from .._settings import settings from .._utils import _doc_params from ..preprocessing._normalization import normalize_total @@ -18,7 +18,6 @@ from matplotlib.axes import Axes -@old_positionals("show", "save", "ax", "gene_symbols", "log") @_doc_params(show_save_ax=doc_show_save_ax) def highest_expr_genes( adata: AnnData, diff --git a/src/scanpy/plotting/_scrublet.py b/src/scanpy/plotting/_scrublet.py index 2705419236..385480e6c0 100644 --- a/src/scanpy/plotting/_scrublet.py +++ b/src/scanpy/plotting/_scrublet.py @@ -6,7 +6,6 @@ import pandas as pd from matplotlib import pyplot as plt -from .._compat import old_positionals from ._utils import savefig_or_show if TYPE_CHECKING: @@ -20,9 +19,6 @@ type Scale = Literal["linear", "log", "symlog", "logit"] | str -@old_positionals( - "scale_hist_obs", "scale_hist_sim", "figsize", "return_fig", "show", "save" -) def scrublet_score_distribution( adata: AnnData, *, diff --git a/src/scanpy/plotting/_stacked_violin.py b/src/scanpy/plotting/_stacked_violin.py index 19d6aa7a97..07f20f3bab 100644 --- a/src/scanpy/plotting/_stacked_violin.py +++ b/src/scanpy/plotting/_stacked_violin.py @@ -8,7 +8,7 @@ from matplotlib.colors import is_color_like from .. import logging as logg -from .._compat import old_positionals, warn +from .._compat import warn from .._settings import settings from .._utils import _doc_params, _empty from ._baseplot_class import BasePlot, doc_common_groupby_plot_args @@ -156,25 +156,6 @@ def __getattribute__(self, name: str) -> object: return object.__getattribute__(self, "DEFAULT_SCALE") return object.__getattribute__(self, name) - @old_positionals( - "use_raw", - "log", - "num_categories", - "categories_order", - "title", - "figsize", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "var_group_rotation", - "layer", - "standard_scale", - "ax", - "vmin", - "vmax", - "vcenter", - "norm", - ) def __init__( # noqa: PLR0913 self, adata: AnnData, @@ -257,19 +238,6 @@ def __init__( # noqa: PLR0913 self.kwds.setdefault("linewidth", self.DEFAULT_LINE_WIDTH) self.kwds.setdefault("density_norm", self.DEFAULT_DENSITY_NORM) - @old_positionals( - "cmap", - "stripplot", - "jitter", - "jitter_size", - "linewidth", - "row_palette", - "density_norm", - "yticklabels", - "ylim", - "x_padding", - "y_padding", - ) def style( # noqa: PLR0913 self, *, @@ -641,23 +609,6 @@ def _setup_violin_axes_ticks(self, row_ax: Axes, num_cols: int): ) -@old_positionals( - "log", - "use_raw", - "num_categories", - "title", - "colorbar_title", - "figsize", - "dendrogram", - "gene_symbols", - "var_group_positions", - "var_group_labels", - "standard_scale", - "var_group_rotation", - "layer", - "stripplot", - # 17 positionals are enough for backwards compatibility -) @_doc_params( show_save_ax=doc_show_save_ax, common_plot_args=doc_common_plot_args, diff --git a/src/scanpy/plotting/_tools/__init__.py b/src/scanpy/plotting/_tools/__init__.py index eab7908c87..ce20cea86a 100644 --- a/src/scanpy/plotting/_tools/__init__.py +++ b/src/scanpy/plotting/_tools/__init__.py @@ -14,7 +14,6 @@ from scanpy.get import obs_df from ... import logging as logg -from ..._compat import old_positionals from ..._settings import settings from ..._utils import _doc_params, _empty, sanitize_anndata, with_cat_dtype from ...get import rank_genes_groups_df @@ -107,7 +106,6 @@ def pca_overview(adata: AnnData, **params): pca_scatter = pca -@old_positionals("include_lowest", "n_points", "show", "save") def pca_loadings( adata: AnnData, components: str | Sequence[int] | None = None, @@ -181,7 +179,6 @@ def pca_loadings( savefig_or_show("pca_loadings", show=show, save=save) -@old_positionals("log", "show", "save") def pca_variance_ratio( adata: AnnData, n_pcs: int = 30, @@ -225,7 +222,6 @@ def pca_variance_ratio( # ------------------------------------------------------------------------------ -@old_positionals("color_map", "show", "save", "as_heatmap", "marker") def dpt_timeseries( adata: AnnData, *, @@ -271,7 +267,6 @@ def dpt_timeseries( savefig_or_show("dpt_timeseries", save=save, show=show) -@old_positionals("color_map", "palette", "show", "save", "marker") @_doc_params(cm_palette=doc_cm_palette, show_save=doc_show_save) def dpt_groups_pseudotime( adata: AnnData, @@ -329,17 +324,6 @@ def dpt_groups_pseudotime( return fig -@old_positionals( - "n_genes", - "gene_symbols", - "key", - "fontsize", - "ncols", - "sharey", - "show", - "save", - "ax", -) @_doc_params(show_save_ax=doc_show_save_ax) def rank_genes_groups( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, @@ -689,16 +673,6 @@ def _rank_genes_groups_plot( # noqa: PLR0912, PLR0913, PLR0915 ) -@old_positionals( - "n_genes", - "groupby", - "gene_symbols", - "var_names", - "min_logfoldchange", - "key", - "show", - "save", -) @_doc_params(params=doc_rank_genes_groups_plot_args, show_save_ax=doc_show_save_ax) def rank_genes_groups_heatmap( adata: AnnData, @@ -772,16 +746,6 @@ def rank_genes_groups_heatmap( ) -@old_positionals( - "n_genes", - "groupby", - "var_names", - "gene_symbols", - "min_logfoldchange", - "key", - "show", - "save", -) @_doc_params(params=doc_rank_genes_groups_plot_args, show_save_ax=doc_show_save_ax) def rank_genes_groups_tracksplot( adata: AnnData, @@ -834,18 +798,6 @@ def rank_genes_groups_tracksplot( ) -@old_positionals( - "n_genes", - "groupby", - "values_to_plot", - "var_names", - "gene_symbols", - "min_logfoldchange", - "key", - "show", - "save", - "return_fig", -) @_doc_params( params=doc_rank_genes_groups_plot_args, vals_to_plot=doc_rank_genes_groups_values_to_plot, @@ -997,7 +949,6 @@ def rank_genes_groups_dotplot( # noqa: PLR0913 ) -@old_positionals("n_genes", "groupby", "gene_symbols") @_doc_params(params=doc_rank_genes_groups_plot_args, show_save_ax=doc_show_save_ax) def rank_genes_groups_stacked_violin( # noqa: PLR0913 adata: AnnData, @@ -1061,18 +1012,6 @@ def rank_genes_groups_stacked_violin( # noqa: PLR0913 ) -@old_positionals( - "n_genes", - "groupby", - "values_to_plot", - "var_names", - "gene_symbols", - "min_logfoldchange", - "key", - "show", - "save", - "return_fig", -) @_doc_params( params=doc_rank_genes_groups_plot_args, vals_to_plot=doc_rank_genes_groups_values_to_plot, @@ -1206,21 +1145,6 @@ def rank_genes_groups_matrixplot( # noqa: PLR0913 ) -@old_positionals( - "n_genes", - "gene_names", - "gene_symbols", - "use_raw", - "key", - "split", - "density_norm", - "strip", - "jitter", - "size", - "ax", - "show", - "save", -) @_doc_params(show_save_ax=doc_show_save_ax) def rank_genes_groups_violin( # noqa: PLR0913 adata: AnnData, @@ -1349,7 +1273,6 @@ def rank_genes_groups_violin( # noqa: PLR0913 return axs -@old_positionals("tmax_realization", "as_heatmap", "shuffle", "show", "save", "marker") def sim( adata: AnnData, *, @@ -1424,26 +1347,6 @@ def sim( savefig_or_show("sim_shuffled", save=save, show=show) -@old_positionals( - "key", - "groupby", - "group", - "color_map", - "bg_dotsize", - "fg_dotsize", - "vmax", - "vmin", - "vcenter", - "norm", - "ncols", - "hspace", - "wspace", - "title", - "show", - "save", - "ax", - "return_fig", -) @_doc_params( vminmax=doc_vbound_percentile, panels=doc_panels, show_save_ax=doc_show_save_ax ) diff --git a/src/scanpy/plotting/_tools/paga.py b/src/scanpy/plotting/_tools/paga.py index 633448592a..2fb9276fe8 100644 --- a/src/scanpy/plotting/_tools/paga.py +++ b/src/scanpy/plotting/_tools/paga.py @@ -19,7 +19,7 @@ from ... import _utils as _sc_utils from ... import logging as logg -from ..._compat import CSBase, old_positionals +from ..._compat import CSBase from ..._settings import settings from .. import _utils from .._utils import matrix @@ -39,29 +39,6 @@ type _Layout = _LayoutWithoutEqTree | Literal["eq_tree"] -@old_positionals( - "edges", - "color", - "alpha", - "groups", - "components", - "projection", - "legend_loc", - "legend_fontsize", - "legend_fontweight", - "legend_fontoutline", - "color_map", - "palette", - "frameon", - "size", - "title", - "right_margin", - "left_margin", - "show", - "save", - "title_graph", - "groups_graph", -) def paga_compare( # noqa: PLR0912, PLR0913 adata: AnnData, basis=None, @@ -354,25 +331,6 @@ def make_pos( return make_pos({}) -@old_positionals( - "threshold", - "color", - "layout", - "layout_kwds", - "init_pos", - "root", - "labels", - "single_component", - "solid_edges", - "dashed_edges", - "transitions", - "fontsize", - "fontweight", - "fontoutline", - "text_kwds", - "node_size_scale", - # 17 positionals are enough for backwards compat -) def paga( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, *, @@ -1089,31 +1047,6 @@ def _paga_graph( # noqa: PLR0912, PLR0913, PLR0915 return sct -@old_positionals( - "use_raw", - "annotations", - "color_map", - "color_maps_annotations", - "palette_groups", - "n_avg", - "groups_key", - "xlim", - "title", - "left_margin", - "ytick_fontsize", - "title_fontsize", - "show_node_names", - "show_yticks", - "show_colorbar", - "legend_fontsize", - "legend_fontweight", - "normalize_to_zero_one", - "as_heatmap", - "return_data", - "show", - "save", - "ax", -) def paga_path( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, nodes: Sequence[str | int], diff --git a/src/scanpy/plotting/_utils.py b/src/scanpy/plotting/_utils.py index 05e159f158..6a265502a1 100644 --- a/src/scanpy/plotting/_utils.py +++ b/src/scanpy/plotting/_utils.py @@ -16,7 +16,7 @@ from matplotlib.patches import Circle from .. import logging as logg -from .._compat import old_positionals, warn +from .._compat import warn from .._settings import settings from .._utils import NeighborsView, _empty from . import palettes @@ -108,18 +108,6 @@ class _AxesSubplot(Axes, axes.SubplotBase): # ------------------------------------------------------------------------------- -@old_positionals( - "xlabel", - "ylabel", - "xticks", - "yticks", - "title", - "colorbar_shrink", - "color_map", - "show", - "save", - "ax", -) def matrix( # noqa: PLR0913 matrix: ArrayLike | Image, *, diff --git a/src/scanpy/preprocessing/_combat.py b/src/scanpy/preprocessing/_combat.py index b063eb33f7..1abcd3002a 100644 --- a/src/scanpy/preprocessing/_combat.py +++ b/src/scanpy/preprocessing/_combat.py @@ -7,7 +7,7 @@ from numpy import linalg as la from .. import logging as logg -from .._compat import CSBase, old_positionals +from .._compat import CSBase from .._utils import sanitize_anndata if TYPE_CHECKING: @@ -133,7 +133,6 @@ def _standardize_data( return s_data, design, var_pooled, stand_mean -@old_positionals("covariates", "inplace") def combat( # noqa: PLR0915 adata: AnnData, key: str = "batch", diff --git a/src/scanpy/preprocessing/_deprecated/__init__.py b/src/scanpy/preprocessing/_deprecated/__init__.py index 97c68451c5..28cd1dbcf5 100644 --- a/src/scanpy/preprocessing/_deprecated/__init__.py +++ b/src/scanpy/preprocessing/_deprecated/__init__.py @@ -3,11 +3,10 @@ import numpy as np from scipy import sparse -from ..._compat import CSBase, old_positionals +from ..._compat import CSBase from ..._utils import dematrix -@old_positionals("max_fraction", "mult_with_mean") def normalize_per_cell_weinreb16_deprecated( x: np.ndarray | CSBase, *, diff --git a/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py b/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py index c1db3d654b..3269b3c5bd 100644 --- a/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py +++ b/src/scanpy/preprocessing/_deprecated/highly_variable_genes.py @@ -9,7 +9,7 @@ from fast_array_utils.stats import mean_var from ... import logging as logg -from ..._compat import CSBase, deprecated, old_positionals, warn +from ..._compat import CSBase, deprecated, warn from .._distributed import materialize_as_ndarray if TYPE_CHECKING: @@ -17,18 +17,6 @@ @deprecated("Use sc.pp.highly_variable_genes instead") -@old_positionals( - "flavor", - "min_disp", - "max_disp", - "min_mean", - "max_mean", - "n_bins", - "n_top_genes", - "log", - "subset", - "copy", -) def filter_genes_dispersion( # noqa: PLR0912, PLR0913, PLR0915 data: AnnData | CSBase | np.ndarray, *, diff --git a/src/scanpy/preprocessing/_deprecated/sampling.py b/src/scanpy/preprocessing/_deprecated/sampling.py index 2280f3c9a0..b153b9489f 100644 --- a/src/scanpy/preprocessing/_deprecated/sampling.py +++ b/src/scanpy/preprocessing/_deprecated/sampling.py @@ -2,7 +2,6 @@ from typing import TYPE_CHECKING -from ..._compat import old_positionals from ..._utils.random import legacy_numpy_gen from .._simple import sample @@ -15,7 +14,6 @@ from ..._utils.random import _LegacyRandom -@old_positionals("n_obs", "random_state", "copy") def subsample( data: AnnData | np.ndarray | CSBase, fraction: float | None = None, diff --git a/src/scanpy/preprocessing/_highly_variable_genes.py b/src/scanpy/preprocessing/_highly_variable_genes.py index 906f0fb16e..12da9ae24b 100644 --- a/src/scanpy/preprocessing/_highly_variable_genes.py +++ b/src/scanpy/preprocessing/_highly_variable_genes.py @@ -13,7 +13,7 @@ from fast_array_utils import stats from .. import logging as logg -from .._compat import CSBase, CSRBase, DaskArray, old_positionals, warn +from .._compat import CSBase, CSRBase, DaskArray, warn from .._settings import Verbosity, settings from .._utils import ( check_nonnegative_integers, @@ -592,21 +592,6 @@ def _highly_variable_genes_batched( return df -@old_positionals( - "layer", - "n_top_genes", - "min_disp", - "max_disp", - "min_mean", - "max_mean", - "span", - "n_bins", - "flavor", - "subset", - "inplace", - "batch_key", - "check_values", -) def highly_variable_genes( # noqa: PLR0913 adata: AnnData, *, diff --git a/src/scanpy/preprocessing/_normalization.py b/src/scanpy/preprocessing/_normalization.py index 6b6184bcf7..db214c3cc6 100644 --- a/src/scanpy/preprocessing/_normalization.py +++ b/src/scanpy/preprocessing/_normalization.py @@ -8,7 +8,7 @@ from fast_array_utils import stats from .. import logging as logg -from .._compat import CSBase, CSCBase, CSRBase, DaskArray, njit, old_positionals, warn +from .._compat import CSBase, CSCBase, CSRBase, DaskArray, njit, warn from .._utils import axis_mul_or_truediv, dematrix, view_to_actual from ..get import _get_obs_rep, _set_obs_rep @@ -123,15 +123,6 @@ def _normalize_total_helper( return x, counts_per_cell, gene_subset -@old_positionals( - "target_sum", - "exclude_highly_expressed", - "max_fraction", - "key_added", - "layer", - "inplace", - "copy", -) def normalize_total( # noqa: PLR0912 adata: AnnData, *, diff --git a/src/scanpy/preprocessing/_recipes.py b/src/scanpy/preprocessing/_recipes.py index d223036873..7ac262b166 100644 --- a/src/scanpy/preprocessing/_recipes.py +++ b/src/scanpy/preprocessing/_recipes.py @@ -6,7 +6,7 @@ from .. import logging as logg from .. import preprocessing as pp -from .._compat import CSBase, old_positionals +from .._compat import CSBase from ._deprecated.highly_variable_genes import ( filter_genes_cv_deprecated, filter_genes_dispersion, @@ -19,15 +19,6 @@ from .._utils.random import _LegacyRandom -@old_positionals( - "log", - "mean_threshold", - "cv_threshold", - "n_pcs", - "svd_solver", - "random_state", - "copy", -) def recipe_weinreb17( adata: AnnData, *, @@ -79,7 +70,6 @@ def recipe_weinreb17( return adata if copy else None -@old_positionals("log", "plot", "copy") def recipe_seurat( adata: AnnData, *, log: bool = True, plot: bool = False, copy: bool = False ) -> AnnData | None: @@ -123,7 +113,6 @@ def recipe_seurat( return adata if copy else None -@old_positionals("n_top_genes", "log", "plot", "copy") def recipe_zheng17( adata: AnnData, *, diff --git a/src/scanpy/preprocessing/_scale.py b/src/scanpy/preprocessing/_scale.py index 751cecfdc2..fe49308445 100644 --- a/src/scanpy/preprocessing/_scale.py +++ b/src/scanpy/preprocessing/_scale.py @@ -10,13 +10,12 @@ from fast_array_utils.stats import mean_var from .. import logging as logg -from .._compat import CSBase, CSCBase, CSRBase, DaskArray, njit, old_positionals, warn +from .._compat import CSBase, CSCBase, CSRBase, DaskArray, njit, warn from .._utils import ( axis_mul_or_truediv, check_array_function_arguments, dematrix, raise_not_implemented_error_if_backed_type, - renamed_arg, view_to_actual, ) from ..get import _check_mask, _get_obs_rep, _set_obs_rep @@ -67,8 +66,6 @@ def clip_array( return x -@renamed_arg("X", "data", pos_0=True) -@old_positionals("zero_center", "max_value", "copy", "layer", "obsm") @singledispatch def scale[A: _Array]( data: AnnData | A, diff --git a/src/scanpy/preprocessing/_scrublet/__init__.py b/src/scanpy/preprocessing/_scrublet/__init__.py index b8ea1a267c..a5a080e814 100644 --- a/src/scanpy/preprocessing/_scrublet/__init__.py +++ b/src/scanpy/preprocessing/_scrublet/__init__.py @@ -10,7 +10,6 @@ from ... import logging as logg from ... import preprocessing as pp -from ..._compat import old_positionals from ...get import _get_obs_rep from . import pipeline from .core import Scrublet @@ -20,25 +19,6 @@ from ...neighbors import _Metric, _MetricFn -@old_positionals( - "batch_key", - "sim_doublet_ratio", - "expected_doublet_rate", - "stdev_doublet_rate", - "synthetic_doublet_umi_subsampling", - "knn_dist_metric", - "normalize_variance", - "log_transform", - "mean_center", - "n_prin_comps", - "use_approx_neighbors", - "get_doublet_neighbor_parents", - "n_neighbors", - "threshold", - "verbose", - "copy", - "random_state", -) def scrublet( # noqa: PLR0913 adata: AnnData, adata_sim: AnnData | None = None, @@ -502,9 +482,6 @@ def _scrublet_call_doublets( # noqa: PLR0913 return adata_obs -@old_positionals( - "layer", "sim_doublet_ratio", "synthetic_doublet_umi_subsampling", "random_seed" -) def scrublet_simulate_doublets( adata: AnnData, *, diff --git a/src/scanpy/preprocessing/_simple.py b/src/scanpy/preprocessing/_simple.py index 9eebeb0246..d2092592da 100644 --- a/src/scanpy/preprocessing/_simple.py +++ b/src/scanpy/preprocessing/_simple.py @@ -19,14 +19,13 @@ from sklearn.utils import check_array, sparsefuncs from .. import logging as logg -from .._compat import CSBase, CSRBase, DaskArray, deprecated, njit, old_positionals +from .._compat import CSBase, CSRBase, DaskArray, deprecated, njit from .._settings import settings as sett from .._utils import ( _resolve_axis, check_array_function_arguments, is_backed_type, raise_not_implemented_error_if_backed_type, - renamed_arg, sanitize_anndata, view_to_actual, ) @@ -44,9 +43,6 @@ from .._utils.random import RNGLike, SeedLike, _LegacyRandom -@old_positionals( - "min_counts", "min_genes", "max_counts", "max_genes", "inplace", "copy" -) def filter_cells( data: AnnData | CSBase | np.ndarray | DaskArray, *, @@ -193,9 +189,6 @@ def filter_cells( return cell_subset, number_per_cell -@old_positionals( - "min_counts", "min_cells", "max_counts", "max_cells", "inplace", "copy" -) def filter_genes( data: AnnData | CSBase | np.ndarray | DaskArray, *, @@ -306,7 +299,6 @@ def filter_genes( return gene_subset, number_per_gene -@renamed_arg("X", "data", pos_0=True) @singledispatch def log1p( data: AnnData | np.ndarray | CSBase, @@ -424,7 +416,6 @@ def log1p_anndata( return adata -@old_positionals("copy", "chunked", "chunk_size") def sqrt( data: AnnData | CSBase | np.ndarray, *, @@ -468,15 +459,6 @@ def sqrt( @deprecated("Use `sc.pp.normalize_total` instead.") -@old_positionals( - "counts_per_cell_after", - "counts_per_cell", - "key_n_counts", - "copy", - "layers", - "use_rep", - "min_counts", -) def normalize_per_cell( data: AnnData | np.ndarray | CSBase, *, @@ -672,7 +654,6 @@ def numpy_regress_out( return data -@old_positionals("layer", "n_jobs", "copy") def regress_out( adata: AnnData, keys: str | Sequence[str], @@ -990,7 +971,6 @@ def sample( # noqa: PLR0912 return subset, indices -@renamed_arg("target_counts", "counts_per_cell") def downsample_counts( adata: AnnData, counts_per_cell: int | Collection[int] | None = None, diff --git a/src/scanpy/readwrite.py b/src/scanpy/readwrite.py index ec0b9804a0..f549cb83d9 100644 --- a/src/scanpy/readwrite.py +++ b/src/scanpy/readwrite.py @@ -17,7 +17,7 @@ from packaging.version import Version from . import logging as logg -from ._compat import deprecated, old_positionals, pkg_version, warn +from ._compat import deprecated, pkg_version, warn from ._settings import AnnDataFileFormat, settings from ._utils import _empty @@ -79,15 +79,6 @@ # -------------------------------------------------------------------------------- -@old_positionals( - "sheet", - "ext", - "delimiter", - "first_column_names", - "backup_url", - "cache", - "cache_compression", -) def read( filename: PathLike[str] | str, backed: Literal["r", "r+"] | None = None, @@ -174,7 +165,6 @@ def read( return read_h5ad(filename, backed=backed) -@old_positionals("genome", "gex_only", "backup_url") def read_10x_h5( filename: PathLike[str] | str, *, @@ -533,7 +523,6 @@ def read_visium( return adata -@old_positionals("var_names", "make_unique", "cache", "cache_compression", "gex_only") def read_10x_mtx( path: PathLike[str] | str, *, @@ -646,7 +635,6 @@ def _read_10x_mtx( return adata -@old_positionals("ext", "compression", "compression_opts") def write( filename: PathLike[str] | str, adata: AnnData, @@ -746,7 +734,6 @@ def write_zarr(filename: PathLike[str] | str, adata: AnnData, **kw) -> None: # ------------------------------------------------------------------------------- -@old_positionals("as_header") def read_params( filename: PathLike[str] | str, *, as_header: bool = False ) -> dict[str, int | float | bool | str | None]: diff --git a/src/scanpy/tools/_dendrogram.py b/src/scanpy/tools/_dendrogram.py index 8cd3e7e851..80882cf3fb 100644 --- a/src/scanpy/tools/_dendrogram.py +++ b/src/scanpy/tools/_dendrogram.py @@ -8,7 +8,6 @@ from pandas.api.types import CategoricalDtype from .. import logging as logg -from .._compat import old_positionals from .._utils import _doc_params, raise_not_implemented_error_if_backed_type from ..neighbors._doc import doc_n_pcs, doc_use_rep from ._utils import _choose_representation @@ -20,17 +19,6 @@ from anndata import AnnData -@old_positionals( - "n_pcs", - "use_rep", - "var_names", - "use_raw", - "cor_method", - "linkage_method", - "optimal_ordering", - "key_added", - "inplace", -) @_doc_params(n_pcs=doc_n_pcs, use_rep=doc_use_rep) def dendrogram( # noqa: PLR0913 adata: AnnData, diff --git a/src/scanpy/tools/_diffmap.py b/src/scanpy/tools/_diffmap.py index 62fa55b92e..de4538dfc2 100644 --- a/src/scanpy/tools/_diffmap.py +++ b/src/scanpy/tools/_diffmap.py @@ -2,7 +2,6 @@ from typing import TYPE_CHECKING -from .._compat import old_positionals from ._dpt import _diffmap if TYPE_CHECKING: @@ -11,7 +10,6 @@ from .._utils.random import _LegacyRandom -@old_positionals("neighbors_key", "random_state", "copy") def diffmap( adata: AnnData, n_comps: int = 15, diff --git a/src/scanpy/tools/_dpt.py b/src/scanpy/tools/_dpt.py index 2a52633026..603202b01b 100644 --- a/src/scanpy/tools/_dpt.py +++ b/src/scanpy/tools/_dpt.py @@ -8,7 +8,6 @@ from natsort import natsorted from .. import logging as logg -from .._compat import old_positionals from ..neighbors import Neighbors, OnFlySymMatrix if TYPE_CHECKING: @@ -35,9 +34,6 @@ def _diffmap(adata, n_comps=15, neighbors_key=None, random_state=0): ) -@old_positionals( - "n_branchings", "min_group_size", "allow_kendall_tau_shift", "neighbors_key", "copy" -) def dpt( adata: AnnData, n_dcs: int = 10, diff --git a/src/scanpy/tools/_draw_graph.py b/src/scanpy/tools/_draw_graph.py index a76bad1c30..ffb6fd1048 100644 --- a/src/scanpy/tools/_draw_graph.py +++ b/src/scanpy/tools/_draw_graph.py @@ -8,7 +8,6 @@ from .. import _utils from .. import logging as logg -from .._compat import old_positionals from .._utils import _choose_graph, get_literal_vals from ._utils import get_init_pos_from_paga @@ -24,17 +23,6 @@ type _Layout = Literal["fr", "drl", "kk", "grid_fr", "lgl", "rt", "rt_circular", "fa"] -@old_positionals( - "init_pos", - "root", - "random_state", - "n_jobs", - "adjacency", - "key_added_ext", - "neighbors_key", - "obsp", - "copy", -) def draw_graph( # noqa: PLR0913 adata: AnnData, layout: _Layout = "fa", diff --git a/src/scanpy/tools/_embedding_density.py b/src/scanpy/tools/_embedding_density.py index 63ff098d5a..37e2bcf606 100644 --- a/src/scanpy/tools/_embedding_density.py +++ b/src/scanpy/tools/_embedding_density.py @@ -7,7 +7,6 @@ import numpy as np from .. import logging as logg -from .._compat import old_positionals from .._utils import sanitize_anndata if TYPE_CHECKING: @@ -33,7 +32,6 @@ def _calc_density(x: np.ndarray, y: np.ndarray): return scaled_z -@old_positionals("groupby", "key_added", "components") def embedding_density( # noqa: PLR0912 adata: AnnData, basis: str = "umap", diff --git a/src/scanpy/tools/_ingest.py b/src/scanpy/tools/_ingest.py index 8ec53ee462..7bc0e2eb6d 100644 --- a/src/scanpy/tools/_ingest.py +++ b/src/scanpy/tools/_ingest.py @@ -8,7 +8,7 @@ from sklearn.utils import check_random_state from .. import logging as logg -from .._compat import CSBase, old_positionals +from .._compat import CSBase from .._settings import settings from .._utils import NeighborsView, raise_not_implemented_error_if_backed_type from .._utils._doctests import doctest_skip @@ -22,14 +22,6 @@ from ..neighbors import RPForestDict -@old_positionals( - "obs", - "embedding_method", - "labeling_method", - "neighbors_key", - "neighbors_key", - "inplace", -) @doctest_skip("illustrative short example but not runnable") def ingest( adata: AnnData, @@ -452,7 +444,6 @@ def map_labels(self, labels, method): msg = "Ingest supports knn labeling for now." raise NotImplementedError(msg) - @old_positionals("inplace") def to_adata(self, *, inplace: bool = False) -> AnnData | None: """Return `adata_new` with mapped embeddings and labels. diff --git a/src/scanpy/tools/_louvain.py b/src/scanpy/tools/_louvain.py index 00e78d1b5e..439f5b01bf 100644 --- a/src/scanpy/tools/_louvain.py +++ b/src/scanpy/tools/_louvain.py @@ -10,7 +10,7 @@ from .. import _utils from .. import logging as logg -from .._compat import deprecated, old_positionals, pkg_version, warn +from .._compat import deprecated, pkg_version, warn from .._utils import _choose_graph, dematrix from ._utils_clustering import rename_groups, restrict_adjacency @@ -31,20 +31,6 @@ MutableVertexPartition.__module__ = "louvain.VertexPartition" -@old_positionals( - "random_state", - "restrict_to", - "key_added", - "adjacency", - "flavor", - "directed", - "use_weights", - "partition_type", - "partition_kwargs", - "neighbors_key", - "obsp", - "copy", -) @deprecated("Use `scanpy.tl.leiden` instead") def louvain( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, diff --git a/src/scanpy/tools/_paga.py b/src/scanpy/tools/_paga.py index 803afacc3e..f2130b5787 100644 --- a/src/scanpy/tools/_paga.py +++ b/src/scanpy/tools/_paga.py @@ -8,7 +8,6 @@ from .. import _utils from .. import logging as logg -from .._compat import old_positionals from ..neighbors import Neighbors if TYPE_CHECKING: @@ -19,7 +18,6 @@ _AVAIL_MODELS = {"v1.0", "v1.2"} -@old_positionals("use_rna_velocity", "model", "neighbors_key", "copy") def paga( adata: AnnData, groups: str | None = None, diff --git a/src/scanpy/tools/_rank_genes_groups.py b/src/scanpy/tools/_rank_genes_groups.py index 9c1f012c83..8c05453ccd 100644 --- a/src/scanpy/tools/_rank_genes_groups.py +++ b/src/scanpy/tools/_rank_genes_groups.py @@ -12,7 +12,7 @@ from .. import _utils from .. import logging as logg -from .._compat import CSBase, njit, old_positionals +from .._compat import CSBase, njit from .._utils import ( check_nonnegative_integers, get_literal_vals, @@ -488,21 +488,6 @@ def compute_statistics( # noqa: PLR0912 self.stats.index = self.var_names -@old_positionals( - "mask", - "use_raw", - "groups", - "reference", - "n_genes", - "rankby_abs", - "pts", - "key_added", - "copy", - "method", - "corr_method", - "tie_correct", - "layer", -) def rank_genes_groups( # noqa: PLR0912, PLR0913, PLR0915 adata: AnnData, groupby: str, @@ -773,16 +758,6 @@ def _calc_frac(x: NDArray[np.number] | CSBase, /) -> NDArray[np.float64]: return n_nonzero / x.shape[0] -@old_positionals( - "key", - "groupby", - "use_raw", - "key_added", - "min_in_group_fraction", - "min_fold_change", - "max_out_group_fraction", - "compare_abs", -) def filter_rank_genes_groups( # noqa: PLR0912 adata: AnnData, *, diff --git a/src/scanpy/tools/_score_genes.py b/src/scanpy/tools/_score_genes.py index 426497182d..48ad38ab37 100644 --- a/src/scanpy/tools/_score_genes.py +++ b/src/scanpy/tools/_score_genes.py @@ -8,7 +8,7 @@ import pandas as pd from .. import logging as logg -from .._compat import CSBase, old_positionals +from .._compat import CSBase from .._utils import check_use_raw, is_backed_type from ..get import _get_obs_rep @@ -49,9 +49,6 @@ def _sparse_nanmean(x: CSBase, /, axis: Literal[0, 1]) -> NDArray[np.float64]: return m -@old_positionals( - "ctrl_size", "gene_pool", "n_bins", "score_name", "random_state", "copy", "use_raw" -) def score_genes( # noqa: PLR0913 adata: AnnData, gene_list: Sequence[str] | pd.Index[str], @@ -258,7 +255,6 @@ def _nan_means( return np.nanmean(x, axis=axis, dtype=dtype) -@old_positionals("s_genes", "g2m_genes", "copy") def score_genes_cell_cycle( adata: AnnData, *, diff --git a/src/scanpy/tools/_sim.py b/src/scanpy/tools/_sim.py index 84654dcc54..39ff7ee32c 100644 --- a/src/scanpy/tools/_sim.py +++ b/src/scanpy/tools/_sim.py @@ -24,7 +24,6 @@ from .. import _utils, readwrite from .. import logging as logg -from .._compat import old_positionals from .._settings import settings if TYPE_CHECKING: @@ -34,17 +33,6 @@ from anndata import AnnData -@old_positionals( - "params_file", - "tmax", - "branching", - "nrRealizations", - "noiseObs", - "noiseDyn", - "step", - "seed", - "writedir", -) def sim( model: Literal["krumsiek11", "toggleswitch"], *, diff --git a/src/scanpy/tools/_tsne.py b/src/scanpy/tools/_tsne.py index de3f3a7300..17b8ce279e 100644 --- a/src/scanpy/tools/_tsne.py +++ b/src/scanpy/tools/_tsne.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING from .. import logging as logg -from .._compat import old_positionals, warn +from .._compat import warn from .._settings import settings from .._utils import _doc_params, raise_not_implemented_error_if_backed_type from ..neighbors._doc import doc_n_pcs, doc_use_rep @@ -15,16 +15,6 @@ from .._utils.random import _LegacyRandom -@old_positionals( - "use_rep", - "perplexity", - "early_exaggeration", - "learning_rate", - "random_state", - "use_fast_tsne", - "n_jobs", - "copy", -) @_doc_params(doc_n_pcs=doc_n_pcs, use_rep=doc_use_rep) def tsne( # noqa: PLR0913 adata: AnnData, diff --git a/src/scanpy/tools/_umap.py b/src/scanpy/tools/_umap.py index a1848173fa..0e14a0f4ca 100644 --- a/src/scanpy/tools/_umap.py +++ b/src/scanpy/tools/_umap.py @@ -7,7 +7,7 @@ from sklearn.utils import check_array, check_random_state from .. import logging as logg -from .._compat import old_positionals, warn +from .._compat import warn from .._settings import settings from .._utils import NeighborsView from ._utils import _choose_representation, get_init_pos_from_paga @@ -22,22 +22,6 @@ type _InitPos = Literal["paga", "spectral", "random"] -@old_positionals( - "min_dist", - "spread", - "n_components", - "maxiter", - "alpha", - "gamma", - "negative_sample_rate", - "init_pos", - "random_state", - "a", - "b", - "copy", - "method", - "neighbors_key", -) def umap( # noqa: PLR0913, PLR0915 adata: AnnData, *, diff --git a/tests/test_preprocessing.py b/tests/test_preprocessing.py index 29a71cbfc8..be5897bd09 100644 --- a/tests/test_preprocessing.py +++ b/tests/test_preprocessing.py @@ -80,12 +80,6 @@ def test_log1p(tmp_path): assert np.allclose(ad4.X, a_log / np.log(2)) -def test_log1p_deprecated_arg(): - a = np.random.rand(200, 10).astype(np.float32) - with pytest.warns(FutureWarning, match=r".*`X` was renamed to `data`"): - sc.pp.log1p(X=a) - - @pytest.fixture(params=[None, 2]) def base(request): return request.param