Skip to content

Commit

Permalink
Refactoring (#627)
Browse files Browse the repository at this point in the history
* Removed unused dependencies

Signed-off-by: zethson <[email protected]>

* Tutorials update

Signed-off-by: zethson <[email protected]>

* Readd fhiry

Signed-off-by: zethson <[email protected]>

* Skip jupyter_core

Signed-off-by: zethson <[email protected]>

* Fix import

Signed-off-by: zethson <[email protected]>

* Don't fail session-info

Signed-off-by: zethson <[email protected]>

* Revert session info change

Signed-off-by: zethson <[email protected]>

* Refactoring

Signed-off-by: zethson <[email protected]>

* Session info

Signed-off-by: zethson <[email protected]>

---------

Signed-off-by: zethson <[email protected]>
  • Loading branch information
Zethson authored Dec 18, 2023
1 parent 9c2de8c commit 8ce852d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 47 deletions.
30 changes: 17 additions & 13 deletions ehrapy/core/meta_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ def print_versions(): # pragma: no cover
>>> import ehrapy as ep
>>> ep.print_versions()
"""
session_info.show(
dependencies=True,
html=False,
excludes=[
"builtins",
"stdlib_list",
"importlib_metadata",
"jupyter_core"
# Special module present if test coverage being calculated
# https://gitlab.com/joelostblom/session_info/-/issues/10
"$coverage",
],
)
try:
session_info.show(
dependencies=True,
html=False,
excludes=[
"builtins",
"stdlib_list",
"importlib_metadata",
"jupyter_core"
# Special module present if test coverage being calculated
# https://gitlab.com/joelostblom/session_info/-/issues/10
"$coverage",
],
)
except AttributeError:
print("[bold yellow]Unable to fetch versions for one or more dependencies.")
pass


def print_version_and_date(*, file=None): # pragma: no cover
Expand Down
33 changes: 0 additions & 33 deletions ehrapy/io/_utility_io.py

This file was deleted.

28 changes: 27 additions & 1 deletion ehrapy/io/_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import numpy as np

from ehrapy import settings
from ehrapy.io._utility_io import _get_file_extension
from ehrapy.preprocessing._encode import encode

if TYPE_CHECKING:
from anndata import AnnData

supported_extensions = {"csv", "tsv", "h5ad"}


def write(
filename: str | Path,
Expand Down Expand Up @@ -69,6 +70,31 @@ def write(
adata.write(filename, compression=compression, compression_opts=compression_opts)


def _get_file_extension(file_path: Path) -> str:
"""Check whether the argument is a filename.
Args:
file_path: Path to the file.
Returns:
File extension of the specified file
"""
ext = file_path.suffixes

if len(ext) > 2:
ext = ext[-2:]

if ext and ext[-1][1:] in supported_extensions:
return ext[-1][1:]
raise ValueError(
f"""\
{file_path!r} does not end on a valid extension.
Please, provide one of the available extensions.
{supported_extensions}
"""
)


def _get_filename_from_key(key, extension=None) -> Path:
"""Gets full file name from a key.
Expand Down

0 comments on commit 8ce852d

Please sign in to comment.