Skip to content

Replace wall-clock guards in equality tests with operation counts - #781

Merged
ViralBShah merged 2 commits into
mainfrom
vs/test-op-count-guards
Sep 8, 2026
Merged

Replace wall-clock guards in equality tests with operation counts#781
ViralBShah merged 2 commits into
mainfrom
vs/test-op-count-guards

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

Follow-up to #766 and #768 (and item 6 of the test-time review).

The @elapsed(...) < 0.1 assertions guarding the stored-entries-only isequal/== paths are wall-clock thresholds, which are the main flake risk on loaded CI runners. The matrix variants also build 10^5 x 10^5 matrices (an 800 KB column-pointer array each) for seven wrapper combinations.

They are replaced with a deterministic check. sparsematrix_ops.jl already has a Counting eltype whose == increments a global counter; this PR gives it isequal too and asserts that comparing two sparse arrays performs at most nnz(A) + nnz(B) element comparisons. The generic AbstractArray fallback would perform length(A) of them, so a regression to it fails the test regardless of machine speed. The check covers vectors, matrices, and all adjoint/transpose combinations, for both == and isequal.

The existing NaN, signed-zero, stored-zero and dimension-mismatch semantics tests are unchanged apart from running at small sizes.

#769 adds similar timing guards for findprev and hash; I'll convert those the same way once it merges.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LgBHUw9Hp7YW5ub29B4R5y

The `@elapsed(...) < 0.1` assertions added for the stored-entries-only
`isequal`/`==` paths are wall-clock thresholds on shared CI runners, and the
matrix variants build 10^5 x 10^5 matrices (800 KB column pointers) for
each of several wrapper combinations. Replace them with a deterministic
check: using the existing `Counting` eltype in sparsematrix_ops.jl, assert
that a comparison performs at most nnz(A) + nnz(B) element comparisons,
where the generic AbstractArray fallback would perform length(A). The
NaN, signed-zero and stored-zero semantics tests are kept at small sizes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LgBHUw9Hp7YW5ub29B4R5y
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@944c623). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #781   +/-   ##
=======================================
  Coverage        ?   92.06%           
=======================================
  Files           ?       12           
  Lines           ?     8377           
  Branches        ?        0           
=======================================
  Hits            ?     7712           
  Misses          ?      665           
  Partials        ?        0           

☔ 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.

@ViralBShah
ViralBShah merged commit 8c75f98 into main Sep 8, 2026
10 checks passed
@ViralBShah
ViralBShah deleted the vs/test-op-count-guards branch September 8, 2026 13:17
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.

1 participant