theislab / ehrapy

Electronic Health Record Analysis with Python.
https://ehrapy.readthedocs.io/
Apache License 2.0
235 stars 19 forks source link

Add tests for pass through calls of scanpy functions #792

Open eroell opened 3 months ago

eroell commented 3 months ago

Description of feature

We are right now not testing the pass through calls of scanpy functions work smoothly. As we are using the public scanpy API and watch scanpy closely, I don't expect this to cause a lot of troubles.

Nonetheless it would be great to check during CI that this remains the case I think - else these functions are hardly covered during testing.

E.g. we could check

from types import MappingProxyType
from unittest.mock import patch

import ehrapy as ep  # import your_pass_through_function

def test_pass_through_function(adata_mini):
    with patch("scanpy.pp.neighbors") as mock_scanpy_neighbors:

        ep.pp.neighbors(adata_mini)

        mock_scanpy_neighbors.assert_called_once_with(
            adata=adata_mini,
            n_neighbors=15,
            n_pcs=None,
            use_rep=None,
            knn=True,
            random_state=0,
            method="umap",
            transformer=None,
            metric="euclidean",
            metric_kwds=MappingProxyType({}),
            key_added=None,
            copy=False
            )

Thoughts @Zethson?

eroell commented 2 months ago

Or have a test function which merely calls they scanpy function, ensuring all of them run once. Also test against scanpy main, for earlier checks on development.

This includes modifying the testing CI wait for Python3.12 support PR