Skip to content

Commit

Permalink
Fix CI (#844)
Browse files Browse the repository at this point in the history
* Fix CI

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

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix CI

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

* Fix CI

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

* Fix CI

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

---------

Signed-off-by: zethson <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Zethson and pre-commit-ci[bot] authored Jan 6, 2025
1 parent 4903d6a commit 8e00c45
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ default_stages:
- pre-push
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
5 changes: 5 additions & 0 deletions ehrapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
__email__ = "[email protected]"
__version__ = "0.9.0"

import os

# https://docs.scipy.org/doc/scipy/dev/api-dev/array_api.html
os.environ["SCIPY_ARRAY_API"] = "1"

from ehrapy._settings import EhrapyConfig, ehrapy_settings

settings: EhrapyConfig = ehrapy_settings
Expand Down
49 changes: 9 additions & 40 deletions ehrapy/core/meta_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import sys
from datetime import datetime

import session_info
from rich import print
from scanpy.logging import _versions_dependencies

from ehrapy import __version__

Expand All @@ -17,23 +15,7 @@ def print_versions(): # pragma: no cover
>>> import ehrapy as ep
>>> ep.print_versions()
"""
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
print_header()


def print_version_and_date(*, file=None): # pragma: no cover
Expand All @@ -47,26 +29,13 @@ def print_version_and_date(*, file=None): # pragma: no cover


def print_header(*, file=None): # pragma: no cover
"""Versions that might influence the numerical results.
"""Versions that might influence the numerical results."""
from session_info2 import session_info

Matplotlib and Seaborn are excluded from this.
"""
_DEPENDENCIES_NUMERICS = [
"scanpy",
"anndata",
"umap",
"numpy",
"scipy",
"pandas",
("sklearn", "scikit-learn"),
"statsmodels",
("igraph", "python-igraph"),
"leidenalg",
"pynndescent",
]
sinfo = session_info(os=True, cpu=True, gpu=True, dependencies=True)

modules = ["ehrapy"] + _DEPENDENCIES_NUMERICS
print(
" ".join(f"{mod}=={ver}" for mod, ver in _versions_dependencies(modules)),
file=file or sys.stdout,
)
if file is not None:
print(sinfo, file=file)
return

return sinfo
3 changes: 2 additions & 1 deletion ehrapy/tools/feature_ranking/_rank_features_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections.abc import Iterable
from typing import TYPE_CHECKING, Literal

import anndata as ad
import numpy as np
import pandas as pd
import scanpy as sc
Expand Down Expand Up @@ -446,7 +447,7 @@ def rank_features_groups(
X_to_keep = np.zeros((len(adata), 1))
var_to_keep = pd.DataFrame({"dummy": [0]})

adata_minimal = sc.AnnData(
adata_minimal = ad.AnnData(
X=X_to_keep,
obs=adata.obs,
var=var_to_keep,
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ classifiers = [
]

dependencies = [
"session-info",
"session-info2",
"lamin_utils",
"rich",
"scanpy[leiden]",
Expand Down Expand Up @@ -135,7 +135,8 @@ filterwarnings = [
"ignore:X converted to numpy array with dtype object:UserWarning",
"ignore:`flavor='seurat_v3'` expects raw count data, but non-integers were found:UserWarning",
"ignore:All-NaN slice encountered:RuntimeWarning",
"ignore:Observation names are not unique. To make them unique, call `.obs_names_make_unique`.:UserWarning"
"ignore:Observation names are not unique. To make them unique, call `.obs_names_make_unique`.:UserWarning",
"ignore:Trying to modify attribute .var of view"
]
minversion = 6.0
norecursedirs = [ '.*', 'build', 'dist', '*.egg', 'data', '__pycache__']
Expand Down
4 changes: 2 additions & 2 deletions tests/anndata/test_anndata_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def setup_binary_df_to_anndata() -> DataFrame:
col2_val = ["another_str" + str(idx) for idx in range(100)]
col3_val = [0 for _ in range(100)]
col4_val = [1.0 for _ in range(100)]
col5_val = [0.0 if idx % 2 == 0 else np.NaN for idx in range(100)]
col5_val = [0.0 if idx % 2 == 0 else np.nan for idx in range(100)]
col6_val = [idx % 2 for idx in range(100)]
col7_val = [float(idx % 2) for idx in range(100)]
col8_val = [idx % 3 if idx % 3 in {0, 1} else np.NaN for idx in range(100)]
col8_val = [idx % 3 if idx % 3 in {0, 1} else np.nan for idx in range(100)]
df = DataFrame(
{
"col1": col1_val,
Expand Down
22 changes: 11 additions & 11 deletions tests/preprocessing/test_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ def test_norm_power_kwargs(array_type, adata_to_norm):
num1_norm = np.array([201.03636, 1132.8341, 1399.3877], dtype=np.float32)
num2_norm = np.array([-1.8225479, 5.921072, 3.397709], dtype=np.float32)

assert np.allclose(adata_norm.X[:, 3], num1_norm)
assert np.allclose(adata_norm.X[:, 4], num2_norm)
assert np.allclose(adata_norm.X[:, 3], num1_norm, rtol=1e-02, atol=1e-02)
assert np.allclose(adata_norm.X[:, 4], num2_norm, rtol=1e-02, atol=1e-02)


@pytest.mark.parametrize("array_type", ARRAY_TYPES)
Expand Down Expand Up @@ -540,18 +540,18 @@ def test_norm_power_group(array_type, adata_mini):
)
col2_norm = np.array(
[
-1.34342372,
-0.44542197,
0.44898626,
1.33985944,
-1.34344617,
-0.4453993,
0.44900845,
1.33983703,
-1.3504524,
-0.43539175,
0.4501508,
1.3356934,
-1.3437141,
-0.44512963,
0.44927517,
1.3395685,
],
dtype=np.float32,
)
assert np.allclose(adata_mini_norm.X[:, 0], adata_mini_casted.X[:, 0])
assert np.allclose(adata_mini_norm.X[:, 0], adata_mini_casted.X[:, 0], rtol=1e-02, atol=1e-02)
assert np.allclose(adata_mini_norm.X[:, 1], col1_norm, rtol=1e-02, atol=1e-02)
assert np.allclose(adata_mini_norm.X[:, 2], col2_norm, rtol=1e-02, atol=1e-02)

Expand Down

0 comments on commit 8e00c45

Please sign in to comment.