Skip to content

TST: Add arithmetic compatibility tests.#1038

Open
genedan wants to merge 1 commit into
mainfrom
dunders_tests
Open

TST: Add arithmetic compatibility tests.#1038
genedan wants to merge 1 commit into
mainfrom
dunders_tests

Conversation

@genedan

@genedan genedan commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

Add some tests for uncovered lines in dunders.py, dealing with arithmetic operations on Triangles with different grain and backends.

Related GitHub Issue(s)

Additional Context for Reviewers

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)

Note

Low Risk
Test-only changes with no production code modifications.

Overview
Adds regression tests in test_arithmetic.py for dunders.py arithmetic behavior that was previously untested.

Backend promotion: sparse Triangle + numpy.ndarray, and numpy Triangle + sparse COO, should both yield a sparse backend and match raa + 1 when converted to numpy.

Grain guard: adding triangles with mismatched grain (e.g. raa vs qtr) must raise ValueError with the message that both triangles need the same grain.

Existing arithmetic tests are unchanged aside from new imports and typing (TYPE_CHECKING, Triangle fixture annotations).

Reviewed by Cursor Bugbot for commit b024736. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.35%. Comparing base (468f11a) to head (b024736).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1038      +/-   ##
==========================================
+ Coverage   89.21%   89.35%   +0.14%     
==========================================
  Files          89       89              
  Lines        5165     5169       +4     
  Branches      661      661              
==========================================
+ Hits         4608     4619      +11     
+ Misses        390      386       -4     
+ Partials      167      164       -3     
Flag Coverage Δ
unittests 89.35% <100.00%> (+0.14%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@henrydingliu

Copy link
Copy Markdown
Collaborator

ah, splendid. i've had an issue with sparse arithmetic forever.

the behavior below seems counter-intuitive when adding any two sparse triangles return a sparse triangle. would you consider this to already covered by these new test?

clrd = cl.load_sample('clrd').set_backend('sparse')
clrd_gr = clrd.groupby('GRNAME').sum()
print(clrd.array_backend)
print(clrd_gr.array_backend)
sparse
numpy

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