Skip to content

test(pybind): drop shadow-name guard, cover @= identity (follow-up to #986) - #1009

Merged
yingjerkao merged 1 commit into
masterfrom
fix/inplace-test-cleanup
Jul 7, 2026
Merged

test(pybind): drop shadow-name guard, cover @= identity (follow-up to #986)#1009
yingjerkao merged 1 commit into
masterfrom
fix/inplace-test-cleanup

Conversation

@yingjerkao

Copy link
Copy Markdown
Collaborator

Follow-up to the merged #986, addressing the two review comments on pytests/binding_inplace_test.py.

Changes

  • Remove test_shadow_bindings_are_gone (per @IvanaGyro, review comment: "This test is useless for the future code. This should be clean up."). It only asserts that the deleted c__*/c_* shadow names are absent — a one-time migration guard with no value for future code, and the last place in the tree that even referenced those dead names.

  • Add test_imatmul_preserves_identity (per @pcchen's approval follow-up). @= is the one genuine behavioral change from refactor(pybind): bind in-place methods directly, drop the c__* shadow API #986: on master the wrapper was misspelled def __imatmul (missing the trailing __), so a @= b fell back to a = a @ b and rebound a to a new object. With __imatmul__ bound correctly it now mutates in place and preserves identity. This path was previously untested.

Verification

Built the Python module from the post-#986 tree and ran the file:

Net: −29/+15 (one dead test out, one meaningful test in).

🤖 Generated with Claude Code

Follow-up to the merged #986, addressing review feedback on
pytests/binding_inplace_test.py:

- Remove test_shadow_bindings_are_gone (@IvanaGyro). It only asserts that the
  deleted c__*/c_* shadow names are absent -- a one-time migration guard with no
  value for future code, and the last place those dead names were referenced.

- Add test_imatmul_preserves_identity (@pcchen). `@=` is the one genuine
  behavioral change from #986: the old wrapper was misspelled `def __imatmul`
  (no trailing `__`), so `a @= b` fell back to `a = a @ b` and rebound `a` to a
  new object. With __imatmul__ bound correctly it now mutates in place and
  preserves identity; this was previously untested.

Verified against a fresh build: the new test passes on the post-#986 module
(real __imatmul__) and fails on the pre-#986 module (fallback rebinds a), so it
genuinely pins the fixed behavior. Full file: 7 passed.

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the test_shadow_bindings_are_gone test case and adds a new test test_imatmul_preserves_identity to verify that the @= operator correctly performs in-place matrix multiplication and preserves object identity. There are no review comments, so we have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.82%. Comparing base (d6dcd16) to head (aed1fb5).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1009   +/-   ##
=======================================
  Coverage   31.82%   31.82%           
=======================================
  Files         230      230           
  Lines       33124    33124           
  Branches    13852    13852           
=======================================
  Hits        10543    10543           
  Misses      15539    15539           
  Partials     7042     7042           
Flag Coverage Δ
cpp 31.46% <ø> (ø)
python 61.84% <ø> (ø)

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

Components Coverage Δ
C++ backend 32.55% <ø> (ø)
Python bindings 24.02% <ø> (ø)
Python package 61.84% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6dcd16...aed1fb5. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pcchen

pcchen commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Code Review

Clean, correct test-only follow-up to #986 that closes both review comments on binding_inplace_test.py. LGTM.

  • test_imatmul_preserves_identity is correct and non-vacuous. It snapshots expected = Dot(a, b) before the @= (independent storage), then asserts both identity (a is alias, id(a) == aid) and correctness (alias - expected has zero norm). The == 0.0 exact check is safe here since the operands are small exact-integer values. Per the PR notes, the test also fails on the pre-refactor(pybind): bind in-place methods directly, drop the c__* shadow API #986 module (where @= rebound a to a new object) — so it genuinely pins the fixed behavior rather than passing vacuously.
  • Removing test_shadow_bindings_are_gone is reasonable — it only asserted the deleted c__*/c_* names are absent (a one-time migration guard with no value for future code), and it was the last reference to those dead names.
  • No collateral: Type is still used by test_storage_pylist_roundtrip, so the removal doesn't orphan the import.
  • CI is fully greenBuildAndTest (Linux + macOS) + pytest + all wheels + codecov all pass on the current commit; base is up-to-date with master.

No findings — a strict improvement to the test suite.

Posted by Claude Code on behalf of @pcchen

@pcchen pcchen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Correct, non-vacuous @= identity test (snapshots Dot(a,b) before the in-place op, asserts identity + zero-norm correctness, and per the PR notes fails on the pre-#986 module), reasonable removal of the one-time shadow-name migration guard, no orphaned imports, and full test CI (BuildAndTest Linux+macOS, pytest, wheels, codecov) green on the current commit. Closes both #986 review comments.

Posted by Claude Code on behalf of @pcchen

@yingjerkao
yingjerkao merged commit b19d68c into master Jul 7, 2026
19 checks passed
@yingjerkao
yingjerkao deleted the fix/inplace-test-cleanup branch July 7, 2026 11:44
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