Fix C3dMapper.__eq__() early return skipping remaining keys#384
Open
yasumorishima wants to merge 5 commits intopyomeca:devfrom
Open
Fix C3dMapper.__eq__() early return skipping remaining keys#384yasumorishima wants to merge 5 commits intopyomeca:devfrom
yasumorishima wants to merge 5 commits intopyomeca:devfrom
Conversation
Closes pyomeca#383 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The meta_points dict contains numpy arrays directly (not parameter-style dicts), so the else branch needs to handle numpy array comparison to avoid "truth value of an empty array is ambiguous" ValueError. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address CodeRabbit review: use np.random.default_rng(42) instead of np.random.rand for deterministic test results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pariterre
approved these changes
Feb 12, 2026
Member
pariterre
left a comment
There was a problem hiding this comment.
@pariterre reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @yasumorishima).
Member
|
@yasumorishima |
Author
|
Thank you for the review and approval! No rush at all — enjoy your vacation. I'm happy to help with anything when you're back. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #383
Fixes two early-return bugs in
C3dMapper.__eq__()that caused the comparison to stop after checking only the first key, instead of iterating through all keys.Changes
Bug 1: C3dMapper comparison (line 58)
Bug 2: numpy array comparison (line 62-67)
Bug 3:
__eq_param__numpy array handling (line 106-108)The fix to Bug 1 & 2 causes
meta_points(a dict containing numpy arrays likeresidualsandcamera_masks) to be properly reached and compared. The existingelsebranch in__eq_param__useddict1[key] != dict2[key], which raisesValueErrorfor numpy arrays. Fixed by adding annp.array_equalcheck for numpy array values.Tests
Added
test_eq()with 5 assertions:analogs(notpoints) makes them unequal — this was the core bug: previously returned Trueparameters(notheader) makes them unequal — same bug at top levelNote on
test_parse_and_rebuildfailuresSome existing
test_parse_and_rebuildandtest_parse_and_rebuild_datatests now fail for certain formats (BTS, Optotrak, Vicon, Label2). This is not caused by this PR — it is a pre-existing issue that was masked by the broken__eq__. The old__eq__returnedTrueafter comparing only the first key (points), so the write-read roundtrip data loss in other keys (meta_points,analogs, etc.) was never detected. Theheaderandparameterscomparisons continue to pass for all formats.This change is