Fix free constant init value handling for documented dict inputs - #62
Open
julian-8897 wants to merge 1 commit into
Open
Fix free constant init value handling for documented dict inputs#62julian-8897 wants to merge 1 commit into
julian-8897 wants to merge 1 commit into
Conversation
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
Hi Wassim, I opened this PR to fix a small mismatch between the documented API and the
way free constant initial values were handled internally.
ClassSRdocumentsspe_free_consts_init_valas accepting adictionary keyed by the SPE free constant name, eg.
{"k0": 1.0, "k1": [1.0, 1.1, 1.2]}.But in
check_library_args, that value was still being treated likean ordered sequence. So passing the documented dict form would try
to access
spe_free_consts_init_val[0], which raisesKeyError: 0.The fix is to normalize the input once, before
args_make_tokensisbuilt. After normalization, both supported forms end up as the same
name-keyed dictionary internally:
[1.0, 2.0]and{"k0": 1.0, "k1": 2.0}both become{"k0": 1.0, "k1": 2.0}.I also applied the same normalization to
class_free_consts_init_val, since that argument is documented asaccepting dict input as well and had the same kind of mismatch.
Tests
I added some focused tests for:
spe_free_consts_init_val=NoneNone, sequence, and dict inputscodec.get_libraryandFreeConstantsTableI ran
MPLCONFIGDIR=/private/tmp python -m unittest physo.task.tests.args_handler_UnitTestandMPLCONFIGDIR=/private/ tmp python -m unittest physo.toolkit.tests.codec_UnitTest.Both pass