Skip to content

Commit 3f2a94d

Browse files
authored
Switch to Google docstrings (#101)
* Switch to Google docstrings Signed-off-by: zethson <lukas.heumos@posteo.net> * lazy vitessce Signed-off-by: zethson <lukas.heumos@posteo.net> * spec0 Signed-off-by: zethson <lukas.heumos@posteo.net> * moar docstring fixes Signed-off-by: zethson <lukas.heumos@posteo.net> * fix batch_size Signed-off-by: zethson <lukas.heumos@posteo.net> * remove wrong gitignore entry Signed-off-by: zethson <lukas.heumos@posteo.net> * fix docs Signed-off-by: zethson <lukas.heumos@posteo.net> * fix widgets Signed-off-by: zethson <lukas.heumos@posteo.net> * fix widgets Signed-off-by: zethson <lukas.heumos@posteo.net> --------- Signed-off-by: zethson <lukas.heumos@posteo.net>
1 parent cd258e6 commit 3f2a94d

15 files changed

Lines changed: 267 additions & 357 deletions

File tree

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
matrix:
2727
include:
2828
- os: ubuntu-latest
29-
python: "3.10"
29+
python: "3.11"
3030
- os: ubuntu-latest
31-
python: "3.12"
31+
python: "3.13"
3232
- os: ubuntu-latest
33-
python: "3.12"
33+
python: "3.13"
3434
pip-flags: "--pre"
3535
name: PRE-RELEASE DEPENDENCIES
3636

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ __pycache__/
1818
# docs
1919
/docs/generated/
2020
/docs/_build/
21+
22+
ehrapy_data

docs/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
autosummary_generate = True
7575
autodoc_member_order = "groupwise"
7676
default_role = "literal"
77-
napoleon_google_docstring = False
78-
napoleon_numpy_docstring = True
77+
napoleon_google_docstring = True
78+
napoleon_numpy_docstring = False
7979
napoleon_include_init_with_doc = False
8080
napoleon_use_rtype = True # having a separate entry generally helps readability
8181
napoleon_use_param = True
@@ -106,6 +106,7 @@
106106
"h5py": ("https://docs.h5py.org/en/latest", None),
107107
"scanpy": ("https://scanpy.readthedocs.io/en/stable", None),
108108
"numpy": ("https://numpy.org/doc/stable", None),
109+
"torch": ("https://pytorch.org/docs/main/", None),
109110
"scipy": ("https://docs.scipy.org/doc/scipy", None),
110111
"pandas": ("https://pandas.pydata.org/docs", None),
111112
"zarr": ("https://zarr.readthedocs.io/en/stable", None),

docs/notebooks/omop_ml.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
"metadata": {},
430430
"outputs": [],
431431
"source": [
432-
"dataset = ed.tl.omop.EHRDataset(con, edata, batch_size=5, idxs=None)"
432+
"dataset = ed.tl.omop.EHRDataset(con, edata, idxs=None)"
433433
]
434434
},
435435
{

docs/notebooks/widgets.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ def create_single_option_widget(title_text: str, options: list[str]):
55
"""Create a single-option selection widget (RadioButtons).
66
77
Args:
8-
title_text (str): The title displayed above the radio buttons.
9-
options (list[str]): List of strings representing the radio button options.
10-
default_value (str): The default selected value.
8+
title_text: The title displayed above the radio buttons.
9+
options: List of strings representing the radio button options.
10+
default_value: The default selected value.
1111
12-
Returns
13-
-------
12+
Returns:
1413
tuple: A VBox containing the UI elements and the RadioButtons widget.
1514
"""
1615
title = widgets.HTML(f"<h3>{title_text}</h3>")
@@ -25,11 +24,10 @@ def create_multiple_options_widget(title_text: str, options: list[str]):
2524
"""Create a multiple-option selection widget (SelectMultiple).
2625
2726
Args:
28-
title_text (str): The title displayed above the selection box.
29-
options (list[str]): List of strings representing the options.
27+
title_text: The title displayed above the selection box.
28+
options: List of strings representing the options.
3029
31-
Returns
32-
-------
30+
Returns:
3331
tuple: A VBox containing the UI elements and the SelectMultiple widget.
3432
"""
3533
title = widgets.HTML(f"<h3 style='color: #333; font-family: Arial, sans-serif;'>{title_text}</h3>")

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ optional-dependencies.torch = [
7575

7676
optional-dependencies.vitessce = [
7777
"vitessce[all]>=3.4", # the actual dependency
78-
"zarr<3", # vitessce does not support zarr>=3
78+
"zarr>=2.18.7,<3", # vitessce does not support zarr>=3
7979
]
8080
# https://docs.pypi.org/project_metadata/#project-urls
8181
urls.Documentation = "https://ehrdata.readthedocs.io/"
@@ -133,7 +133,7 @@ lint.ignore = [
133133
lint.per-file-ignores."*/__init__.py" = [ "F401" ]
134134
lint.per-file-ignores."docs/*" = [ "I" ]
135135
lint.per-file-ignores."tests/*" = [ "D" ]
136-
lint.pydocstyle.convention = "numpy"
136+
lint.pydocstyle.convention = "google"
137137

138138
[tool.pytest.ini_options]
139139
testpaths = [ "tests" ]

src/ehrdata/_omop_utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
def get_table_catalog_dict(version: Literal["5.4"] = "5.4"):
77
"""Get the table catalog dictionary of the OMOP CDM.
88
9-
Parameters
10-
----------
11-
version
12-
The version of the OMOP CDM. Currently, only 5.4 is supported.
9+
Args:
10+
version:
11+
The version of the OMOP CDM. Currently, only 5.4 is supported.
1312
14-
Returns
15-
-------
16-
Dictionary: a dictionary of the table catalog. The key is the category of the table, and the value is a list of table names
13+
Returns:
14+
A dictionary of the table catalog. The key is the category of the table, and the value is a list of table names.
1715
"""
1816
table_catalog_dict = {}
1917
table_catalog_dict["Clinical data"] = [

src/ehrdata/core/_optional_modules_import.py renamed to src/ehrdata/core/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def lazy_import_torch():
1+
def lazy_import_torch() -> None:
22
try:
33
import torch
44

src/ehrdata/core/ehrdata.py

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,27 @@
1919

2020

2121
class EHRData(AnnData):
22-
"""EHRData object.
22+
"""Model two and three dimensional electronic health record data.
2323
24-
Inherits `__init__` parameters, methods, and properties from :class:`~anndata.AnnData`.
24+
Extends :class:`~anndata.AnnData` to further support regular and irregular time-series data.
2525
26-
Parameters
27-
----------
28-
X
29-
A #observations × #variables data matrix. A view of the data is used if the
26+
Args:
27+
X: A #observations × #variables data matrix. A view of the data is used if the
3028
data type matches, otherwise, a copy is made.
31-
r
32-
A #observations × #variables × #timesteps data array. A view of the data is used if the
33-
data type matches, otherwise, a copy is made.
34-
obs
35-
Key-indexed one-dimensional observations annotation of length #observations.
36-
var
37-
Key-indexed one-dimensional variables annotation of length #variables.
38-
t
39-
Key-indexed one-dimensional time annotation of length #timesteps.
40-
uns
41-
Key-indexed unstructured annotation.
42-
obsm
43-
Key-indexed multi-dimensional observations annotation of length #observations.
44-
If passing a :class:`~numpy.ndarray`, it needs to have a structured datatype.
45-
varm
46-
Key-indexed multi-dimensional variables annotation of length #variables.
47-
If passing a :class:`~numpy.ndarray`, it needs to have a structured datatype.
48-
layers
49-
Key-indexed multi-dimensional arrays aligned to dimensions of `X`.
50-
shape
51-
Shape tuple (#observations, #variables). Can only be provided if `X` is `None`.
52-
filename
53-
Name of backing file. See :class:`h5py.File`.
54-
filemode
55-
Open mode of backing file. See :class:`h5py.File`.
29+
r: A #observations × #variables × #timesteps data array. A view of the data is used if
30+
the data type matches, otherwise, a copy is made.
31+
obs: Key-indexed one-dimensional observations annotation of length #observations.
32+
var: Key-indexed one-dimensional variables annotation of length #variables.
33+
t: Key-indexed one-dimensional time annotation of length #timesteps.
34+
uns: Key-indexed unstructured annotation.
35+
obsm: Key-indexed multi-dimensional observations annotation of length #observations.
36+
If passing a :class:`numpy.ndarray`, it needs to have a structured datatype.
37+
varm: Key-indexed multi-dimensional variables annotation of length #variables.
38+
If passing a :class:`numpy.ndarray`, it needs to have a structured datatype.
39+
layers: Key-indexed multi-dimensional arrays aligned to dimensions of `X`.
40+
shape: Shape tuple (#observations, #variables). Can only be provided if `X` is None.
41+
filename: Name of backing file. See :class:`h5py.File`.
42+
filemode: Open mode of backing file. See :class:`h5py.File`.
5643
"""
5744

5845
_t: pd.DataFrame | None
@@ -174,20 +161,14 @@ def from_adata(
174161
) -> EHRData:
175162
"""Create an EHRData object from an AnnData object.
176163
177-
Parameters
178-
----------
179-
adata
180-
Annotated data object.
181-
r
182-
3-Dimensional tensor, see :attr:`r`.
183-
t
184-
Time dataframe for describing third axis, see :attr:`t`.
185-
tidx
186-
A slice for the 3rd dimension :attr:`r`. Usually, this will be None here.
187-
188-
Returns
189-
-------
190-
An EHRData object.
164+
Args:
165+
adata: Annotated data object.
166+
r: 3-Dimensional tensor, see r attribute.
167+
t: Time dataframe for describing third axis, see t attribute.
168+
tidx: A slice for the 3rd dimension r. Usually, this will be None here.
169+
170+
Returns:
171+
An EHRData object extending the AnnData object.
191172
"""
192173
instance = cls(shape=adata.shape)
193174

@@ -371,14 +352,11 @@ def __repr__(self) -> str:
371352
def __getitem__(self, index: Index | None) -> EHRData:
372353
"""Slice the EHRData object along 1–3 axes.
373354
374-
Parameters
375-
----------
376-
index
377-
1D, 2D, or 3D index.
355+
Args:
356+
index: 1D, 2D, or 3D index.
378357
379-
Returns
380-
-------
381-
An EHRData view object.
358+
Returns:
359+
An EHRData view object.
382360
"""
383361
oidx, vidx, tidx = self._unpack_index(index)
384362
adata_sliced = super().__getitem__((oidx, vidx))

src/ehrdata/dt/dataloader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def download(
2323
2424
Args:
2525
url: URL to download.
26-
download_path: Where the data should be downloaded to.
26+
saving_path: Where the data should be downloaded to.
27+
block_size: Download block size.
28+
overwrite: Whether to overwrite existing data.
2729
"""
2830
# note: tar.gz has to be before gz for the _remove_archive_extension function to remove the entire extension
2931
compression_formats = ["tar.gz", "zip", "tar", "gz", "bz", "xz"]

0 commit comments

Comments
 (0)