Skip to content

Commit

Permalink
Improve test design (#651)
Browse files Browse the repository at this point in the history
Signed-off-by: zethson <[email protected]>
  • Loading branch information
Zethson authored Feb 3, 2024
1 parent 4725a33 commit a376f0c
Show file tree
Hide file tree
Showing 8 changed files with 702 additions and 698 deletions.
2 changes: 1 addition & 1 deletion ehrapy/data/_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ehrapy import ehrapy_settings
from ehrapy.io._read import read_csv, read_fhir, read_h5ad
from ehrapy.preprocessing._encode import encode
from ehrapy.preprocessing._encoding import encode

if TYPE_CHECKING:
import pandas as pd
Expand Down
8 changes: 4 additions & 4 deletions ehrapy/io/_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ehrapy import ehrapy_settings, settings
from ehrapy.anndata.anndata_ext import df_to_anndata
from ehrapy.data._dataloader import download, remove_archive_extension
from ehrapy.preprocessing._encode import encode
from ehrapy.preprocessing._encoding import encode

if TYPE_CHECKING:
from collections.abc import Iterator
Expand Down Expand Up @@ -498,7 +498,7 @@ def _read_from_cache_dir(cache_dir: Path) -> dict[str, AnnData]:
def _read_from_cache(path_cache: Path) -> AnnData:
"""Read AnnData object from cached file."""
cached_adata = read_h5(path_cache)
# type cast required when dealing with non numerical data; otherwise all values in X would be treated as strings
# type cast required when dealing with non-numerical data; otherwise all values in X would be treated as strings
if not np.issubdtype(cached_adata.X.dtype, np.number):
cached_adata.X = cached_adata.X.astype("object")
try:
Expand Down Expand Up @@ -530,7 +530,7 @@ def _write_cache_dir(
index_column: The index columns for each object (if any)
Returns:
A dict containing an unique identifier and an :class:`~anndata.AnnData` object for each file read
A dict containing a unique identifier and an :class:`~anndata.AnnData` object for each file read
"""
for identifier in adata_objects:
# for each identifier (for the AnnData object), we need the index column and obs_only cols (if any) for reuse when reading cache
Expand All @@ -549,7 +549,7 @@ def _write_cache(
"""Write AnnData object to cache"""
original_x_dtype = raw_anndata.X.dtype
if not np.issubdtype(original_x_dtype, np.number):
cached_adata = encode(data=raw_anndata, autodetect=True)
cached_adata = encode(adata=raw_anndata, autodetect=True)
else:
cached_adata = raw_anndata
# temporary key that stores all column names that are obs only for this AnnData object
Expand Down
2 changes: 1 addition & 1 deletion ehrapy/io/_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np

from ehrapy import settings
from ehrapy.preprocessing._encode import encode
from ehrapy.preprocessing._encoding import encode

if TYPE_CHECKING:
from anndata import AnnData
Expand Down
2 changes: 1 addition & 1 deletion ehrapy/preprocessing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ehrapy.preprocessing._encode import encode, undo_encoding
from ehrapy.preprocessing._encoding import encode, undo_encoding
from ehrapy.preprocessing._highly_variable_features import highly_variable_features
from ehrapy.preprocessing._imputation import (
explicit_impute,
Expand Down
432 changes: 198 additions & 234 deletions ehrapy/preprocessing/_encode.py → ehrapy/preprocessing/_encoding.py

Large diffs are not rendered by default.

Loading

0 comments on commit a376f0c

Please sign in to comment.