From bb6d188b08059626165f5a390e24c23ed97dc4a2 Mon Sep 17 00:00:00 2001 From: zethson Date: Mon, 6 Jan 2025 15:03:17 +0100 Subject: [PATCH] Fix CI Signed-off-by: zethson --- .github/pull_request_template.md | 8 ++-- CODE_OF_CONDUCT.md | 28 +++++------ README.md | 8 ++-- docs/contributing.md | 18 +++---- docs/index.md | 6 +-- docs/installation.md | 8 ++-- ehrapy/__init__.py | 5 ++ ehrapy/core/meta_information.py | 48 ++++--------------- .../feature_ranking/_rank_features_groups.py | 3 +- pyproject.toml | 5 +- tests/anndata/test_anndata_ext.py | 4 +- tests/preprocessing/test_normalization.py | 20 ++++---- 12 files changed, 69 insertions(+), 92 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 0bafff61..4214c3b8 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,10 +4,10 @@ -- [ ] This comment contains a description of changes (with reason) -- [ ] Referenced issue is linked -- [ ] If you've fixed a bug or added code that should be tested, add tests! -- [ ] Documentation in `docs` is updated +- [ ] This comment contains a description of changes (with reason) +- [ ] Referenced issue is linked +- [ ] If you've fixed a bug or added code that should be tested, add tests! +- [ ] Documentation in `docs` is updated **Description of changes** diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 39816a93..d6209cca 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,23 +14,23 @@ religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -- The use of sexualized language or imagery and unwelcome sexual - attention or advances -- Trolling, insulting/derogatory comments, and personal or political - attacks -- Public or private harassment -- Publishing others’ private information, such as a physical or - electronic address, without explicit permission -- Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery and unwelcome sexual + attention or advances +- Trolling, insulting/derogatory comments, and personal or political + attacks +- Public or private harassment +- Publishing others’ private information, such as a physical or + electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Our Responsibilities diff --git a/README.md b/README.md index 6c4533b4..32e66dec 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,10 @@ ## Features -- Exploratory and targeted analysis of Electronic Health Records -- Quality control & preprocessing -- Visualization & Exploration -- Clustering & trajectory inference +- Exploratory and targeted analysis of Electronic Health Records +- Quality control & preprocessing +- Visualization & Exploration +- Clustering & trajectory inference ## Installation diff --git a/docs/contributing.md b/docs/contributing.md index 0a5b318e..ce5858eb 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -126,11 +126,11 @@ in the cookiecutter-scverse template. Please write documentation for new or changed features and use-cases. This project uses [sphinx][] with the following features: -- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text -- Google-style docstrings -- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks)) -- [Sphinx autodoc typehints][], to automatically reference annotated input and output types -- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/) +- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text +- Google-style docstrings +- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks)) +- [Sphinx autodoc typehints][], to automatically reference annotated input and output types +- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/) See the [scanpy developer docs](https://scanpy.readthedocs.io/en/latest/dev/documentation.html) for more information on how to write documentation. @@ -144,10 +144,10 @@ These notebooks come from [pert-tutorials](https://github.com/theislab/ehrapy-tu #### Hints -- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only - if you do so can sphinx automatically create a link to the external documentation. -- If building the documentation fails because of a missing link that is outside your control, you can add an entry to - the `nitpick_ignore` list in `docs/conf.py` +- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only + if you do so can sphinx automatically create a link to the external documentation. +- If building the documentation fails because of a missing link that is outside your control, you can add an entry to + the `nitpick_ignore` list in `docs/conf.py` #### Building the docs locally diff --git a/docs/index.md b/docs/index.md index 03a0987d..56cc3037 100644 --- a/docs/index.md +++ b/docs/index.md @@ -61,8 +61,8 @@ medRxiv 2023.12.11.23299816; doi: https://doi.org/10.1101/2023.12.11.23299816 ]( # Indices and tables -- {ref}`genindex` -- {ref}`modindex` -- {ref}`search` +- {ref}`genindex` +- {ref}`modindex` +- {ref}`search` [scanpy genome biology (2018)]: https://doi.org/10.1186/s13059-017-1382-0 diff --git a/docs/installation.md b/docs/installation.md index b349394e..ba7010a9 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -51,10 +51,10 @@ pip install ehrapy[medcat] Available language models are -- en_core_web_md (python -m spacy download en_core_web_md) -- en-core-sci-sm (pip install ) -- en-core-sci-md (pip install ) -- en-core-sci-lg (pip install ) +- en_core_web_md (python -m spacy download en_core_web_md) +- en-core-sci-sm (pip install ) +- en-core-sci-md (pip install ) +- en-core-sci-lg (pip install ) [github repo]: https://github.com/theislab/ehrapy [pip]: https://pip.pypa.io diff --git a/ehrapy/__init__.py b/ehrapy/__init__.py index 53d9b85e..0255cd2a 100644 --- a/ehrapy/__init__.py +++ b/ehrapy/__init__.py @@ -4,6 +4,11 @@ __email__ = "lukas.heumos@posteo.net" __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 diff --git a/ehrapy/core/meta_information.py b/ehrapy/core/meta_information.py index 9af10c6b..57a14306 100644 --- a/ehrapy/core/meta_information.py +++ b/ehrapy/core/meta_information.py @@ -3,7 +3,6 @@ import sys from datetime import datetime -import session_info from rich import print from scanpy.logging import _versions_dependencies @@ -17,23 +16,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 @@ -47,26 +30,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 diff --git a/ehrapy/tools/feature_ranking/_rank_features_groups.py b/ehrapy/tools/feature_ranking/_rank_features_groups.py index 6fb3932c..dc778868 100644 --- a/ehrapy/tools/feature_ranking/_rank_features_groups.py +++ b/ehrapy/tools/feature_ranking/_rank_features_groups.py @@ -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 @@ -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, diff --git a/pyproject.toml b/pyproject.toml index 7bc35d29..654d9092 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ classifiers = [ ] dependencies = [ - "session-info", + "session-info2", "lamin_utils", "rich", "scanpy[leiden]", @@ -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__'] diff --git a/tests/anndata/test_anndata_ext.py b/tests/anndata/test_anndata_ext.py index 6e5bbf83..8e50635a 100644 --- a/tests/anndata/test_anndata_ext.py +++ b/tests/anndata/test_anndata_ext.py @@ -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, diff --git a/tests/preprocessing/test_normalization.py b/tests/preprocessing/test_normalization.py index 5067b237..0caa0cbb 100644 --- a/tests/preprocessing/test_normalization.py +++ b/tests/preprocessing/test_normalization.py @@ -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) @@ -540,14 +540,14 @@ 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.3650659, + -0.41545486, + 0.45502198, + 1.3254988, + -1.3427324, + -0.4461177, + 0.44829938, + 1.3405508, ], dtype=np.float32, )