Skip to content

Fix transformation equality for mismatched axes - #1269

Open
yyli-leo wants to merge 1 commit into
scverse:mainfrom
yyli-leo:review/issue-1205-transform-equality
Open

yyli-leo wants to merge 1 commit into
scverse:mainfrom
yyli-leo:review/issue-1205-transform-equality

Conversation

@yyli-leo

@yyli-leo yyli-leo commented Oct 7, 2026

Copy link
Copy Markdown

Fixes #1205.

Comparing Translation, Scale, or Affine objects with different axis counts can raise a NumPy broadcasting ValueError before the axis comparison returns False. Check the ordered axes before calling np.allclose, preserving the existing type checks and numerical tolerances. Affine already validates matrix dimensions against its input/output axes during construction.

Add 31 parameterized regression and control cases covering mismatched axis counts in both operand orders, independent Affine input/output mismatches, ==/!=, Sequence comparisons, numerical tolerances, axis order/names, and unrelated types.

Validation on Linux, Python 3.12.15, NumPy 2.4.6, at ea93a37203d187020c5d50a7f984dbf8c264a3ae:

  • Original production code with the new tests: 10 intended broadcasting failures, 21 passed.
  • Patched production code with the same test IDs: 31 passed.
  • Full suite with pytest -q -n 2 --dist worksteal --run-network: 1458 passed, 7 skipped, 2 xfailed. The skips and expected failures cover existing unsupported cases.
  • Ruff lint/format checks on both changed files, configured mypy over 58 source files, pip check, and git diff --check: passed.

The full Python/OS/dependency matrix and the reported Xenium end-to-end workflow were not run locally.

AI assistance was used to prepare and validate this change.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.42%. Comparing base (ea93a37) to head (52d471a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1269      +/-   ##
==========================================
+ Coverage   91.40%   91.42%   +0.01%     
==========================================
  Files          53       53              
  Lines        8381     8381              
==========================================
+ Hits         7661     7662       +1     
+ Misses        720      719       -1     
Files with missing lines Coverage Δ
src/spatialdata/transformations/transformations.py 84.28% <100.00%> (+0.16%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Scale/Translation/Affine.__eq__ raise ValueError for a different number of axes (breaks aggregate on Xenium transcripts vs 2D cells)

1 participant