Fixing size parameter handling in len-mechanism to handle function parameters with different size parameters#2138
Fixing size parameter handling in len-mechanism to handle function parameters with different size parameters#2138
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2138 +/- ##
==========================================
+ Coverage 90.09% 90.12% +0.03%
==========================================
Files 71 71
Lines 18662 18675 +13
==========================================
+ Hits 16813 16831 +18
+ Misses 1849 1844 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
It seems we've gone from using flake8 7.1.2 to using flake8 7.3.0 and the new one has this new error code. https://docs.python.org/3/reference/simple_stmts.html#the-global-statement This seems like something we should address in a separate PR. |
You only need the https://stackoverflow.com/questions/291978/short-description-of-the-scoping-rules |
I have added a |
| # If we are being called looking for the ivi-dance, len or code param, we do not care about the size param so we do | ||
| # not call back into ourselves, to avoid infinite recursion | ||
| if parameter_usage_options not in [ParameterUsageOptions.IVI_DANCE_PARAMETER, ParameterUsageOptions.LEN_PARAMETER]: | ||
| # Find the size parameter - we are assuming there can only be one type, either from ivi-dance or len |
There was a problem hiding this comment.
# Find the size parameter - we are assuming there can only be one type, either from ivi-dance or len
You deleted this comment and the if statement guarding population of len size parameters.
But I don't see any testing for mixed usage.
There was a problem hiding this comment.
Thanks Jay.
I added two unit tests that verify ivi-dance and len used together, including a case with multiple len size parameters to cover the mixed usage cases.
build/helper/metadata_filters.py
Outdated
| len_params = filter_len_parameters(parameters) | ||
| for param in len_params: | ||
| len_size_param = find_size_parameter(param, parameters) | ||
| if len_size_param is not None: | ||
| len_size_parameter_names.add(len_size_param['name']) |
There was a problem hiding this comment.
I think it would be better to push most of this logic into a find_size_parameters or find_len_size_parameters or find_len_size_parameter_names function in metadata_find.py.
There was a problem hiding this comment.
Yes.. I included find_len_size_parameter_names method in metadata_find.py which is used in this file.
build/helper/metadata_filters.py
Outdated
| Empty list if no len parameter found | ||
| List of parameters if any are found |
There was a problem hiding this comment.
| Empty list if no len parameter found | |
| List of parameters if any are found | |
| Empty list if no len parameter found | |
| List of parameters dicts if any are found |
| len_size_parameter = helper.find_size_parameter(len_parameters, parameters) | ||
| assert ivi_dance_size_parameter is None or len_size_parameter is None | ||
| len_size_parameters = helper.find_size_parameter(len_parameters, parameters) | ||
| assert ivi_dance_size_parameter is None or len_size_parameters is None |
There was a problem hiding this comment.
So we're not supporting mixed usage, after all?
There was a problem hiding this comment.
We do support mixed usage.
That assert was removed, and mixed ivi-dance + len behavior is now covered by unit tests (including multiple len size parameters).
| len_parameters = helper.filter_len_parameters(parameters) | ||
| len_size_parameter = helper.find_size_parameter(len_parameters, parameters) | ||
| assert ivi_dance_size_parameter is None or len_size_parameter is None | ||
| len_size_parameters = helper.find_size_parameter(len_parameters, parameters) |
There was a problem hiding this comment.
This new variable name is a misleading. helper.find_size_parameter only returns a single parameter.
There was a problem hiding this comment.
Agreed. I have updated the name as before
| len_parameters = helper.filter_len_parameters(parameters) | ||
| len_size_parameter = helper.find_size_parameter(len_parameters, parameters) | ||
| assert ivi_dance_size_parameter is None or len_size_parameter is None | ||
| len_size_parameters = helper.find_size_parameter(len_parameters, parameters) |
There was a problem hiding this comment.
This new variable name is a misleading. helper.find_size_parameter only returns a single parameter.
There was a problem hiding this comment.
I have updated the same pattern in both mako files
src/nifake/metadata/functions.py
Outdated
| 'name': 'dataArraySize', | ||
| 'type': 'ViInt32', | ||
| 'use_array': False, | ||
| 'use_in_python_api': False |
There was a problem hiding this comment.
_add_use_in_python_api should be able to set this to False for the size parameters of type 'len'. If you're having to set it yourself, I think that could be considered a bug.
There was a problem hiding this comment.
Removed and build tox. No issues found. Thanks for highlighting it Jay
I've updated CHANGELOG.md if applicable.What does this Pull Request accomplish?
Fixes the codegen to properly handle functions with multiple array parameters that reference different size parameters:
Updates
metadata_filters.py: Refactors thefilter_parametersfunction to collect all size parameter names referenced by len-sized parameters into alen_size_parameter_names, replacing the previous singlelen_size_parameterapproach. Removed assert to check if all size parameters are same fromfilter_len_parameters. Following this updated var names indefault_method.py.makoandinitialization_method.py.makoto reflect multiple possible size params.Updates to nifake to enable testing: Details covered in testing section
Previously, it was assumed all len-mechanism arrays in a function shared the same size parameter. This change enables functions like
CreateDeembeddingSparameterTableArrayin NI-RFSG wherefrequenciesusesfrequenciesSizeandsparameterTableusessparameterTableSize.List issues fixed by this Pull Request
Issue 2137: Fix size parameter handling for functions with parameters referencing multiple size parameters.
Additional PR needs to be raised to update NI-RFSG function metadata (CreateDeembeddingSparameterTableArray) to consume
these changes.
What testing has been done?
MultipleArraysDifferentSizefunction to nifake metadata with two arrays (valuesArrayusingvaluesArraySize, anddataArrayusingdataArraySize) to test the change in filter param logictest_multiple_arrays_different_sizeintest_library_interpreter.pythat verifies correct handling of multiple arrays with independent size parametersvaluesArraywithvaluesArraySize, and 5 elements fordataArraywithdataArraySize)