Repository navigation
Conversation
SignalObj looks for the name it is assigned to by walking the call stack and comparing the first local variable of each frame with the new object. The comparison used `in`, that is equality, so a caller whose first local variable was a NumPy array raised "The truth value of an array is ambiguous", and a caller whose first local variable was not yet assigned raised KeyError. The comparison is now by identity, and an unset variable counts as a different object. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 31, 2026
This branch has not been deployed
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.
Creating a
SignalObjinside a function failed in two common cases:RememberInstanceCreationInfowalks the call stack to find the name the new object is assigned to, and compares the first local variable of each frame with the object. The comparison usedin, which tests equality: an array compared element by element, and a variable that was not assigned yet was missing fromf_locals. The comparison is now by identity, withf_locals.get, so an unset variable counts as a different object.The tests in
tests/test_signalobj_creation.pycreate aSignalObjfrom a function whose first local variable is an array and from one whose first local variable is not set yet. Both raised before this change.Checked with Python 3.12, numpy 1.26 and scipy 1.17. The existing tests behave as on
development: the 7 failures there (3 intest_h5io.py, 4 intest_pyttasave.py) are the same with and without this change.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com