Skip to content

fix: restore the test suite on Python 3.12 (pandas 3, anndata 0.13) - #849

Merged
selmanozleyen merged 2 commits into
mainfrom
fix/py312-pandas3-anndata013
Aug 25, 2026
Merged

fix: restore the test suite on Python 3.12 (pandas 3, anndata 0.13)#849
selmanozleyen merged 2 commits into
mainfrom
fix/py312-pandas3-anndata013

Conversation

@Marius1311

Copy link
Copy Markdown
Collaborator

The Test workflow is red on main for both 3.12 legs and has been since mid-June — the scheduled run of 2026-08-15 reports 27 failed, 732 passed identically on ubuntu and macOS. The 3.11 leg stays green because it resolves older anndata/pandas. Two unrelated breakages, both dependency drift:

1. Positional indexing of a pandas.Series (24 failures)

src/moscot/base/problems/_mixins.py:288 and :312:

v = np.array(tm_batch.argmax(0))
out.extend(source_df[annotation_label][v[i]] for i in range(len(v)))

v holds positions, while source_df[annotation_label] is a Series indexed by observation names. series[np.int64(0)] therefore relied on pandas' positional fallback for non-integer indexes, which pandas 2 deprecated and pandas 3 removed:

E   KeyError: np.int64(0)
pandas/_libs/index.pyx:583: KeyError

Every test_annotation_mapping case (mapping_mode="max", across the space, time and cross-modality mixins) hits this. Fixed with .iloc, which is exactly what the fallback used to do — so the behaviour is unchanged on older pandas too.

This one is a genuine bug in moscot rather than a test artefact: any user calling annotation_mapping(..., mapping_mode="max") on pandas 3 gets the same KeyError.

2. AnnData.concatenate was removed (3 failures)

tests/problems/base/test_general_problem.py used the long-deprecated method, giving AttributeError: 'AnnData' object has no attribute 'concatenate' in the three test_set_graph_xy cases. Replaced with anndata.concat([...]).

Verification

Full suite on Python 3.12 with anndata 0.13.2 and pandas 3.0.5: 759 passed, 1 skipped, 0 failed (was 732 passed / 27 failed — exactly the 27 restored). black, isort, ruff clean.

Independent of #848 (lint) and #846 (sparsify); together the three take CI back to green.

🤖 Generated with Claude Code

The `Test` workflow has been red on `main` for both 3.12 legs since mid-June - 27 failed,
732 passed, identically on ubuntu and macOS - while 3.11 stays green because it resolves
older anndata/pandas. Two unrelated breakages:

* `_annotation_mapping` indexed a `pandas.Series` positionally: `v` holds `argmax`
  positions while `source_df[annotation_label]` is indexed by observation names, so
  `series[v[i]]` relied on pandas' positional fallback for non-integer indexes. pandas 2
  deprecated it, pandas 3 removed it, and all 24 `test_annotation_mapping` cases fail with
  `KeyError: np.int64(0)`. Use `.iloc`, which is what the fallback did.

* `AnnData.concatenate` was removed in anndata, breaking the three `test_set_graph_xy`
  cases with `AttributeError`. Use `anndata.concat`.

Full suite on 3.12 (anndata 0.13.2, pandas 3.0.5): 759 passed, 1 skipped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.62%. Comparing base (e7a0567) to head (56801ee).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   76.62%   76.62%           
=======================================
  Files          36       36           
  Lines        4175     4175           
  Branches      670      670           
=======================================
  Hits         3199     3199           
  Misses        679      679           
  Partials      297      297           
Files with missing lines Coverage Δ
src/moscot/base/problems/_mixins.py 88.61% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Marius1311

Copy link
Copy Markdown
Collaborator Author

@selmanozleyen, let me know whether I can merge this.

@selmanozleyen
selmanozleyen merged commit 1d4a4bc into main Aug 25, 2026
11 checks passed
@selmanozleyen

Copy link
Copy Markdown
Collaborator

Thanks looks good

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