Skip to content

fix: use weights to calculate modularity, fix umap tests#4045

Merged
flying-sheep merged 5 commits intomainfrom
pa/fix-umap-numba
Apr 10, 2026
Merged

fix: use weights to calculate modularity, fix umap tests#4045
flying-sheep merged 5 commits intomainfrom
pa/fix-umap-numba

Conversation

@flying-sheep
Copy link
Copy Markdown
Member

@flying-sheep flying-sheep commented Apr 9, 2026

  • Closes #
  • Tests included or not required because:

This gets rid of two numba related test skips:

I’ll check if we can backport this or if it pushes the minimum versions too far up

@flying-sheep flying-sheep added this to the 1.12.1 milestone Apr 9, 2026
@flying-sheep flying-sheep changed the title fix: test with compatible umap version tests: test with compatible umap version Apr 9, 2026
@flying-sheep flying-sheep changed the title tests: test with compatible umap version test: use compatible umap version Apr 9, 2026
@flying-sheep flying-sheep marked this pull request as ready for review April 9, 2026 13:01
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@9f523f7). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4045   +/-   ##
=======================================
  Coverage        ?   78.50%           
=======================================
  Files           ?      117           
  Lines           ?    12750           
  Branches        ?        0           
=======================================
  Hits            ?    10009           
  Misses          ?     2741           
  Partials        ?        0           
Flag Coverage Δ
hatch-test.low-vers 77.80% <100.00%> (?)
hatch-test.pre 78.38% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/metrics/_metrics.py 97.18% <100.00%> (ø)

@flying-sheep flying-sheep changed the title test: use compatible umap version fix: use weights to calculate modularity Apr 9, 2026
Comment thread pyproject.toml
"patsy",
"pynndescent>=0.5.13",
"scikit-learn>=1.4.2",
"scikit-learn>=1.6",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

required by umap 0.5.12

@flying-sheep flying-sheep requested a review from ilan-gold April 9, 2026 14:52
igraph_mode: str = ig.ADJ_DIRECTED if is_directed else ig.ADJ_UNDIRECTED
graph: ig.Graph = ig.Graph.Weighted_Adjacency(connectivities, mode=igraph_mode)
return graph.modularity(_codes(labels))
return graph.modularity(_codes(labels), "weight")
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.

Can you explain this a bit? Why was this broken before?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the Graph.Weighted_Adjacency() class method creates a graph with a "weights" edge attribute (parameter default attr='weight'), using the values of the passed sparse matrix as edge weights.

the Graph.modularity() instance method has a weights: str | array | None = None parameter that specify which edge weights to take into account when calculating the modularity.

In #3613 we forgot to specify that.

@flying-sheep flying-sheep requested a review from ilan-gold April 10, 2026 10:24
@flying-sheep flying-sheep merged commit dcba591 into main Apr 10, 2026
17 of 21 checks passed
@flying-sheep flying-sheep deleted the pa/fix-umap-numba branch April 10, 2026 11:16
@scverse scverse deleted a comment from lumberbot-app bot Apr 10, 2026
@flying-sheep flying-sheep changed the title fix: use weights to calculate modularity fix: use weights to calculate modularity, fix umap tests Apr 17, 2026
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.

Integration Testing CI Test Failure on python 3.12 Integration Testing CI Test Failure on python 3.13 with prerelease dependencies

2 participants