-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature/scaling action #38
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #38 +/- ##
===========================================
- Coverage 23.19% 23.12% -0.08%
===========================================
Files 284 290 +6
Lines 30216 30312 +96
Branches 1104 1118 +14
===========================================
Hits 7009 7009
- Misses 23207 23303 +96 ☔ View full report in Codecov by Sentry. |
adbfc0f
to
03cda38
Compare
return; | ||
} | ||
// Apply the scaling factor using std::transform | ||
std::transform(data, data + size, data, |
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.
In this case, std::for_each
is sufficient. It is simpler and thus preferable, I'd say.
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.
I think I disagree in this case, I'm sorry. I think transform makes it clearer as to the context of the underlying action (which in fact is a transformation of data in place). I agree it could be done with for_each but I don't think it would be simpler. Nevertheless I'm also not very partial on this line of code. So if you really prefer for_each I can change the line to
std::for_each(data, data + size, [scaleFactor](Precision& value) { value = static_cast<Precision>(value * scaleFactor); });
|
||
ScaleScaling::ScaleScaling(const config::ComponentConfiguration& compConf) : hasScaling_(false), scaleFactor_{} { | ||
|
||
const auto mappings = compConf.parsedConfig().has("mapping-definition") |
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.
There seems to be some duplication of logic here as well. Can we remove the one in Scale.cc
?
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.
I was weighing that option: I can either create individual plans for fields where scaling is needed or as I currently have add it to plans where only a subset of fields actually need scaling specified by case in the plan. BUT then I wanted to have a check to leave this action as early as possible. I can move the logic in a util function and call it, but this would still be in all three cases. Or I can remove the whole logic of checking as soon as possible. Or I can retrieve the param only in scale.cc and then pass it to the apply function (But this I didn't prefer since I wanted to have the Mapping and scaling as enclosed as possbile sind I pass the metadata anyway and hence have the information anyway)
src/multio/action/scale/Mapping.cc
Outdated
|
||
void ScaleMapping::applyMapping(message::Metadata& md) const { | ||
if (hasMapping_) { | ||
std::string cparam{"xxx"}; |
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.
Same comments here about the logic and duplication (triplication). I'm a bit confused. I think we need this in two places but not in three?
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.
see explanation above. Happy to change but would like to discuss what makes the most sense
2427724
to
d61694d
Compare
Adding scaling action for Climate DT Phase 2 portfolio.