Skip to content

pp test expansion#232

Open
vbrennsteiner wants to merge 3 commits into
mainfrom
pp_test_expansion
Open

pp test expansion#232
vbrennsteiner wants to merge 3 commits into
mainfrom
pp_test_expansion

Conversation

@vbrennsteiner

@vbrennsteiner vbrennsteiner commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Purpose of this PR

Test coverage of pp is de facto complete for all critical parts, the only thing missing was tests for two helpers data_index_to_array & subset_data and some tests for error-branches. This PR adds these missing components and raises the pp test coverage to 100 %.

@vbrennsteiner vbrennsteiner self-assigned this Jun 19, 2026
@vbrennsteiner vbrennsteiner changed the title Pp test expansion pp test expansion Jun 19, 2026

@mschwoer mschwoer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# from the public API. Kept as a documented "None means match-all" guard.
if v is None:
current_mask = pd.Series(True, index=data.index) # noqa: FBT003
current_mask = pd.Series(True, index=data.index) # noqa: FBT003 # pragma: no cover

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why no cover by tests? (for the above raise) statements it might be fine to not cover them, this is a functional piece of logic)

Comment thread tests/pp/test_data.py
apt.pp.add_metadata(adata, md, axis=0)


def test_add_metadata_verbose_log(example_data, caplog):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we gain anything from testing logging?
unless it is super critical, I would remove it (adds to total cost)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean removing the logging altogether or # pragma: no cover the branch?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean removing the test, with an optional pragma

Comment on lines +133 to +134
assert "NA" in result.obs["batch"].tolist()
assert not result.obs["batch"].isna().any()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we test for the full result here?

Comment thread tests/pp/test_data.py
result = data_index_to_array(data, dim_space=dim_space)

# then
assert isinstance(result, np.ndarray)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test for full result.. isinstance is very weak (also for some other tests further down)

Comment thread tests/pp/test_data.py
assert np.array_equal(result, expected)


def test_data_index_to_array_invalid_dim_space(example_data):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstrings? they really help getting the intent (more than just the name)

Comment thread tests/pp/test_data.py
@pytest.mark.parametrize(
("obj", "expected"),
[
("foo", ["foo"]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add: empty list?
("foo", "bar", ["fuh", "baz",]), ?

Comment thread tests/pp/test_data.py
Comment on lines +1488 to +1489
assert isinstance(result, pd.DataFrame)
assert list(result.columns) == ["G1", "G2", "G3"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again: quite weak asserts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants