Skip to content

Commit

Permalink
Add test and actually fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Jan 9, 2025
1 parent 4ed89bc commit 1f6e318
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/scanpy/tools/_rank_genes_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _ranks(
get_chunk = lambda X, left, right: adapt(X[:, left:right])

# Calculate chunk frames
max_chunk = min(_CONST_MAX_SIZE // n_cells, 1)
max_chunk = max(_CONST_MAX_SIZE // n_cells, 1)

for left in range(0, n_genes, max_chunk):
right = min(left + max_chunk, n_genes)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_rank_genes_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ def test_wilcoxon_tie_correction(reference):
np.testing.assert_allclose(test_obj.stats[groups[0]]["pvals"], pvals)


def test_wilcoxon_huge_data(monkeypatch):
max_size = 300
adata = pbmc68k_reduced()
monkeypatch.setattr(sc.tl._rank_genes_groups, "_CONST_MAX_SIZE", max_size)
rank_genes_groups(adata, groupby="bulk_labels", method="wilcoxon")


@pytest.mark.parametrize(
("n_genes_add", "n_genes_out_add"),
[pytest.param(0, 0, id="equal"), pytest.param(2, 1, id="more")],
Expand Down

0 comments on commit 1f6e318

Please sign in to comment.