Repository navigation
Conversation
Input, Output, Flatten, IF, LIF and CubaLIF rewrote the dictionary passed to from_dict before calling NIRNode.from_dict, so a second call on the same dictionary failed with KeyError: 'shape'. Copy it first, as neuromorphs#148 did for NIRNode.from_dict.
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.
Input,Output,Flatten,IF,LIFandCubaLIFoverridefrom_dictand modify the dictionary they receive before callingNIRNode.from_dict(shapeis renamed toinput_type/output_type,v_resetis added). As a consequence, callingfrom_dicttwice on the same dictionary fails:#148 added a copy to
NIRNode.from_dict, but these six overrides write to the argument before reaching it. This PR takes a shallow copy at the top of each of them. Nothing else changes; numpy arrays are still shared, as before.Tests:
test_from_dict_does_not_mutate_input(parametrized over the six node types, including dictionaries withoutv_resetas written by older versions) andtest_graph_from_dict_does_not_mutate_inputcheck that the dictionary is unchanged and that a second call succeeds. They fail onmainand pass with this change. Full suite: 86 passed, 5 skipped, plustest_serialize_deserialize_data, which fails onmainas well on my Windows machine (PermissionErrorwhen h5py reopens aNamedTemporaryFile).This contribution was prepared with the help of an AI assistant (Claude); I reviewed and tested it.