-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🩹 Fix parameter expression parsing #843
🩹 Fix parameter expression parsing #843
Conversation
The naive approach using expression.replace lead to problems when an expression for a parameter was part of another expression for a parameter. Example: The expression: "100 - $inputs1.s1 - $inputs1.s3 - $inputs1.s8 - $inputs1.s12" should have been transformed to: "100 - group.get('inputs1.s1').value - group.get('inputs1.s3').value - group.get('inputs1.s8').value - group.get('inputs1.s12').value" but instead was transformed to: "100 - group.get('inputs1.s1').value - group.get('inputs1.s3').value - group.get('inputs1.s8').value - group.get('inputs1.s1').value2" Since "inputs1.s1" partially matches "inputs1.s12". I also moved the regex compiling out of the class, so it only gets executed when the module is loaded.
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.01%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Benchmark is done. Checkout the benchmark result page. Benchmark diff v0.4.1 vs. mainParametrized benchmark signatures: BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)
Benchmark diff main vs. PRParametrized benchmark signatures: BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)
|
Codecov Report
@@ Coverage Diff @@
## main #843 +/- ##
=======================================
- Coverage 84.9% 84.9% -0.1%
=======================================
Files 77 77
Lines 4373 4371 -2
Branches 786 785 -1
=======================================
- Hits 3713 3711 -2
Misses 521 521
Partials 139 139
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Reviewed and tested out locally. 👍
The naive approach using
expression.replace
lead to problems when an expression for a parameter was part of another expression for a parameter.Example:
The expression:
"100 - $inputs1.s1 - $inputs1.s3 - $inputs1.s8 - $inputs1.s12"
should have been transformed to:
"100 - group.get('inputs1.s1').value - group.get('inputs1.s3').value - group.get('inputs1.s8').value - group.get('inputs1.s12').value"
but instead was transformed to:
"100 - group.get('inputs1.s1').value - group.get('inputs1.s3').value - group.get('inputs1.s8').value - group.get('inputs1.s1').value2"
Since
"inputs1.s1"
partially matches"inputs1.s12"
I also moved the regex compiling out of the class, so it only gets executed when the module is loaded.
Change summary
Checklist