Skip to content

Commit dcd783a

Browse files
committed
document all intended settings attrs
1 parent 5028415 commit dcd783a

File tree

5 files changed

+52
-7
lines changed

5 files changed

+52
-7
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Extension to skip deprecated methods and properties in autosummary."""
2+
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
7+
if TYPE_CHECKING:
8+
from typing import Literal
9+
10+
from sphinx.application import Sphinx
11+
from sphinx.ext.autodoc import Options
12+
13+
14+
def skip_deprecated( # noqa: PLR0917
15+
app: Sphinx,
16+
what: Literal[
17+
"module", "class", "exception", "function", "method", "attribute", "property"
18+
],
19+
name: str,
20+
obj: object,
21+
skip: bool, # noqa: FBT001
22+
options: Options | dict[str, object],
23+
) -> bool | None:
24+
"""Skip deprecated members."""
25+
if hasattr(obj, "__deprecated__"):
26+
return True
27+
return None
28+
29+
30+
def setup(app: Sphinx) -> None:
31+
"""App setup hook."""
32+
app.connect("autodoc-skip-member", skip_deprecated)

docs/release-notes/1.0.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
- {func}`~scanpy.tl.louvain` provides a better implementation for
5151
reclustering via `restrict_to` {smaller}`A Wolf`
5252
- scanpy no longer modifies rcParams upon import, call
53-
`settings.set_figure_params` to set the 'scanpy style' {smaller}`A Wolf`
53+
:func:`scanpy.set_figure_params` to set the 'scanpy style' {smaller}`A Wolf`
5454
- default cache directory is `./cache/`, set `settings.cachedir` to change
5555
this; nested directories in this are avoided {smaller}`A Wolf`
5656
- show edges in scatter plots based on graph visualization

src/scanpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from ._settings import Preset, Verbosity, settings
1919

20-
set_figure_params = settings.set_figure_params
20+
set_figure_params = settings._set_figure_params
2121

2222
import anndata
2323

src/scanpy/_settings.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ class SettingsMeta(SingletonMeta):
140140
_logfile: TextIO | None
141141
_verbosity: Verbosity
142142
# rest
143-
N_PCS: int
144-
"""Default number of principal components to use."""
143+
_n_pcs: int
145144
_plot_suffix: str
146145
_file_format_data: AnnDataFileFormat
147146
_file_format_figs: str
@@ -204,6 +203,16 @@ def verbosity(cls, verbosity: Verbosity | _VerbosityName | int) -> None:
204203
_type_check(verbosity, "verbosity", (str, int))
205204
_set_log_level(cls, _VERBOSITY_TO_LOGLEVEL[cls._verbosity.name])
206205

206+
@property
207+
def N_PCS(cls) -> int:
208+
"""Default number of principal components to use."""
209+
return cls._n_pcs
210+
211+
@N_PCS.setter
212+
def N_PCS(cls, n_pcs: int) -> None:
213+
_type_check(n_pcs, "n_pcs", int)
214+
cls._n_pcs = n_pcs
215+
207216
@property
208217
def plot_suffix(cls) -> str:
209218
"""Global suffix that is appended to figure filenames."""
@@ -408,6 +417,10 @@ def categories_to_ignore(cls, categories_to_ignore: Iterable[str]) -> None:
408417
# Functions
409418
# --------------------------------------------------------------------------------
410419

420+
@deprecated("Use `scanpy.set_figure_params` instead")
421+
def set_figure_params(cls, *args, **kwargs) -> None:
422+
cls.set_figure_params(*args, **kwargs)
423+
411424
@old_positionals(
412425
"scanpy",
413426
"dpi",
@@ -422,7 +435,7 @@ def categories_to_ignore(cls, categories_to_ignore: Iterable[str]) -> None:
422435
"transparent",
423436
"ipython_format",
424437
)
425-
def set_figure_params( # noqa: PLR0913
438+
def _set_figure_params( # noqa: PLR0913
426439
cls,
427440
*,
428441
scanpy: bool = True,
@@ -532,7 +545,7 @@ def __new__(cls) -> type[Self]:
532545
_logpath: ClassVar = None
533546
_verbosity: ClassVar = Verbosity.warning
534547
# rest
535-
N_PCS: ClassVar = 50
548+
_n_pcs: ClassVar = 50
536549
_plot_suffix: ClassVar = ""
537550
_file_format_data: ClassVar = "h5ad"
538551
_file_format_figs: ClassVar = "pdf"

src/scanpy/plotting/_rcmod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def set_rcParams_scanpy(fontsize=14, color_map=None):
1313
"""Set matplotlib.rcParams to Scanpy defaults.
1414
15-
Call this through `settings.set_figure_params`.
15+
Call this through :func:`scanpy.set_figure_params`.
1616
"""
1717
# figure
1818
rcParams["figure.figsize"] = (4, 4)

0 commit comments

Comments
 (0)