Skip to content

Commit de38381

Browse files
authored
Updated missing params in docstrings (#2888)
1 parent f8a5726 commit de38381

File tree

5 files changed

+69
-20
lines changed

5 files changed

+69
-20
lines changed

docs/release-notes/1.10.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
```{rubric} Docs
99
```
1010

11+
* Document several missing parameters in docstring {pr}`2888` {smaller}`S Cheney`
1112
* Fixed incorrect instructions in "testing" dev docs {pr}`2994` {smaller}`I Virshup`
1213
* Update marsilea tutorial to use `group_` methods {pr}`3001` {smaller}`I Virshup`
1314
* Fixed citations {pr}`3032` {smaller}`P Angerer`

scanpy/logging.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ def print_header(*, file=None):
157157
"""\
158158
Versions that might influence the numerical results.
159159
Matplotlib and Seaborn are excluded from this.
160+
161+
Parameters
162+
----------
163+
file
164+
Optional path for dependency output.
160165
"""
161166

162167
modules = ["scanpy"] + _DEPENDENCIES_NUMERICS
@@ -171,6 +176,11 @@ def print_versions(*, file: IO[str] | None = None):
171176
Print versions of imported packages, OS, and jupyter environment.
172177
173178
For more options (including rich output) use `session_info.show` directly.
179+
180+
Parameters
181+
----------
182+
file
183+
Optional path for output.
174184
"""
175185
import session_info
176186

@@ -202,6 +212,11 @@ def print_versions(*, file: IO[str] | None = None):
202212
def print_version_and_date(*, file=None):
203213
"""\
204214
Useful for starting a notebook so you see when you started working.
215+
216+
Parameters
217+
----------
218+
file
219+
Optional path for output.
205220
"""
206221
from . import __version__
207222

@@ -228,7 +243,7 @@ def error(
228243
Log message with specific level and return current time.
229244
230245
Parameters
231-
==========
246+
----------
232247
msg
233248
Message to display.
234249
time

scanpy/plotting/_docs.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,26 @@
4343
Passed to :meth:`~matplotlib.axes.Axes.quiver`\
4444
"""
4545

46+
doc_cm_palette = """\
47+
color_map
48+
Color map to use for continous variables. Can be a name or a
49+
:class:`~matplotlib.colors.Colormap` instance (e.g. `"magma`", `"viridis"`
50+
or `mpl.cm.cividis`), see :func:`~matplotlib.pyplot.get_cmap`.
51+
If `None`, the value of `mpl.rcParams["image.cmap"]` is used.
52+
The default `color_map` can be set using :func:`~scanpy.set_figure_params`.
53+
palette
54+
Colors to use for plotting categorical annotation groups.
55+
The palette can be a valid :class:`~matplotlib.colors.ListedColormap` name
56+
(`'Set2'`, `'tab20'`, …), a :class:`~cycler.Cycler` object, a dict mapping
57+
categories to colors, or a sequence of colors. Colors must be valid to
58+
matplotlib. (see :func:`~matplotlib.colors.is_color_like`).
59+
If `None`, `mpl.rcParams["axes.prop_cycle"]` is used unless the categorical
60+
variable already has colors stored in `adata.uns["{var}_colors"]`.
61+
If provided, values of `adata.uns["{var}_colors"]` will be set.\
62+
"""
63+
4664
# Docs for pl.scatter
47-
doc_scatter_basic = """\
65+
doc_scatter_basic = f"""\
4866
sort_order
4967
For continuous annotations used as color parameter, plot data points
5068
with higher values on top of others.
@@ -81,21 +99,7 @@
8199
Point size. If `None`, is automatically computed as 120000 / n_cells.
82100
Can be a sequence containing the size for each cell. The order should be
83101
the same as in adata.obs.
84-
color_map
85-
Color map to use for continous variables. Can be a name or a
86-
:class:`~matplotlib.colors.Colormap` instance (e.g. `"magma`", `"viridis"`
87-
or `mpl.cm.cividis`), see :func:`~matplotlib.pyplot.get_cmap`.
88-
If `None`, the value of `mpl.rcParams["image.cmap"]` is used.
89-
The default `color_map` can be set using :func:`~scanpy.set_figure_params`.
90-
palette
91-
Colors to use for plotting categorical annotation groups.
92-
The palette can be a valid :class:`~matplotlib.colors.ListedColormap` name
93-
(`'Set2'`, `'tab20'`, …), a :class:`~cycler.Cycler` object, a dict mapping
94-
categories to colors, or a sequence of colors. Colors must be valid to
95-
matplotlib. (see :func:`~matplotlib.colors.is_color_like`).
96-
If `None`, `mpl.rcParams["axes.prop_cycle"]` is used unless the categorical
97-
variable already has colors stored in `adata.uns["{var}_colors"]`.
98-
If provided, values of `adata.uns["{var}_colors"]` will be set.
102+
{doc_cm_palette}
99103
na_color
100104
Color to use for null or masked values. Can be anything matplotlib accepts as a
101105
color. Used for all points if `color=None`.
@@ -179,13 +183,17 @@
179183
for instance: the maximum and minimum values (e.g. `vmin=-2, vmax=5`).\
180184
"""
181185

182-
doc_show_save_ax = """\
186+
doc_show_save = """\
183187
show
184188
Show the plot, do not return axis.
185189
save
186190
If `True` or a `str`, save the figure.
187191
A string is appended to the default filename.
188-
Infer the filetype if ending on {`'.pdf'`, `'.png'`, `'.svg'`}.
192+
Infer the filetype if ending on {`'.pdf'`, `'.png'`, `'.svg'`}.\
193+
"""
194+
195+
doc_show_save_ax = f"""\
196+
{doc_show_save}
189197
ax
190198
A matplotlib axes object. Only works if plotting a single component.\
191199
"""

scanpy/plotting/_tools/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
from ...get import rank_genes_groups_df
2020
from .._anndata import ranking
2121
from .._docs import (
22+
doc_cm_palette,
2223
doc_panels,
2324
doc_rank_genes_groups_plot_args,
2425
doc_rank_genes_groups_values_to_plot,
2526
doc_scatter_embedding,
27+
doc_show_save,
2628
doc_show_save_ax,
2729
doc_vbound_percentile,
2830
)
@@ -265,6 +267,7 @@ def dpt_timeseries(
265267

266268

267269
@old_positionals("color_map", "palette", "show", "save", "marker")
270+
@_doc_params(cm_palette=doc_cm_palette, show_save=doc_show_save)
268271
def dpt_groups_pseudotime(
269272
adata: AnnData,
270273
*,
@@ -274,7 +277,18 @@ def dpt_groups_pseudotime(
274277
save: bool | str | None = None,
275278
marker: str | Sequence[str] = ".",
276279
):
277-
"""Plot groups and pseudotime."""
280+
"""\
281+
Plot groups and pseudotime.
282+
283+
Parameters
284+
----------
285+
adata
286+
Annotated data matrix.
287+
{cm_palette}
288+
{show_save}
289+
marker
290+
Marker style. See :mod:`~matplotlib.markers` for details.
291+
"""
278292
_, (ax_grp, ax_ord) = plt.subplots(2, 1)
279293
timeseries_subplot(
280294
adata.obs["dpt_groups"].cat.codes,

scanpy/preprocessing/_recipes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ def recipe_seurat(
9191
9292
Expects non-logarithmized data.
9393
If using logarithmized data, pass `log=False`.
94+
95+
Parameters
96+
----------
97+
adata
98+
Annotated data matrix.
99+
log
100+
Logarithmize data?
101+
plot
102+
Show a plot of the gene dispersion vs. mean relation.
103+
copy
104+
Return a copy if true.
94105
"""
95106
if copy:
96107
adata = adata.copy()

0 commit comments

Comments
 (0)