Skip to content

Fix Python 3.13 failures in neighborhood enrichment and AnnData test fixture - #120

Open
marcovarrone with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-python-3-13-job
Open

Fix Python 3.13 failures in neighborhood enrichment and AnnData test fixture#120
marcovarrone with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-python-3-13-job

Conversation

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown

The Python 3.13 Actions job failed due to two dependency-compatibility regressions: AnnData(..., dtype=...) in tests and in-place diagonal writes on read-only DataFrame-backed arrays. This PR updates both paths to be compatible with current anndata/numpy behavior while preserving existing semantics.

  • Neighborhood enrichment diagonal handling (src/cellcharter/gr/_nhood.py)

    • Replaced np.fill_diagonal(... .values, np.nan) with DataFrame-level masking to avoid mutating potentially read-only backing arrays.
    • Keeps only_inter=True behavior (diagonal set to NaN) unchanged.
  • AnnData fixture compatibility (tests/conftest.py)

    • Removed deprecated/unsupported dtype argument from AnnData(...).
    • Moved dtype specification to NumPy array construction (np.array(..., dtype=int)).
  • Regression coverage (tests/graph/test_nhood_local.py)

    • Added a focused test that verifies nhood_enrichment(..., only_inter=True, observed_expected=True) returns NaN diagonals for observed/expected/enrichment.
# before
np.fill_diagonal(observed.values, np.nan)

# after
diagonal_mask = np.eye(len(observed), dtype=bool)
observed = observed.mask(diagonal_mask, np.nan)

Copilot AI changed the title [WIP] Fix failing GitHub Actions job Python 3.13 Fix Python 3.13 failures in neighborhood enrichment and AnnData test fixture Jul 26, 2026
Copilot AI requested a review from marcovarrone July 26, 2026 15:02
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.78%. Comparing base (b605238) to head (ac5800f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
- Coverage   68.00%   67.78%   -0.23%     
==========================================
  Files          23       23              
  Lines        1638     1639       +1     
==========================================
- Hits         1114     1111       -3     
- Misses        524      528       +4     
Files with missing lines Coverage Δ
src/cellcharter/gr/_nhood.py 94.68% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcovarrone
marcovarrone marked this pull request as ready for review July 26, 2026 15:21
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