Skip to content
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

Merged
merged 10 commits into from
Nov 27, 2024
Merged

Feature/scaling action #38

merged 10 commits into from
Nov 27, 2024

Conversation

stefaniereuter
Copy link
Contributor

Adding scaling action for Climate DT Phase 2 portfolio.

@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 96 lines in your changes missing coverage. Please review.

Project coverage is 23.12%. Comparing base (9bf71f6) to head (d61694d).

Files with missing lines Patch % Lines
src/multio/action/scale/Scale.cc 0.00% 34 Missing ⚠️
src/multio/action/scale/Mapping.cc 0.00% 20 Missing ⚠️
src/multio/action/scale/Scaling.cc 0.00% 16 Missing ⚠️
src/multio/action/scale/Scaling.h 0.00% 15 Missing ⚠️
src/multio/action/scale/MetadataUtils.cc 0.00% 10 Missing ⚠️
src/multio/action/scale/Mapping.h 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@dsarmany dsarmany force-pushed the feature/scaling-action branch from adbfc0f to 03cda38 Compare November 21, 2024 09:33
src/multio/action/scale/Scale.cc Outdated Show resolved Hide resolved
src/multio/action/scale/Scale.cc Outdated Show resolved Hide resolved
src/multio/action/scale/Scale.cc Outdated Show resolved Hide resolved
src/multio/action/scale/Scale.cc Outdated Show resolved Hide resolved
src/multio/action/scale/Scale.h Outdated Show resolved Hide resolved
return;
}
// Apply the scaling factor using std::transform
std::transform(data, data + size, data,
Copy link
Collaborator

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.

Copy link
Contributor Author

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")
Copy link
Collaborator

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?

Copy link
Contributor Author

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)


void ScaleMapping::applyMapping(message::Metadata& md) const {
if (hasMapping_) {
std::string cparam{"xxx"};
Copy link
Collaborator

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?

Copy link
Contributor Author

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

src/multio/action/scale/Mapping.cc Outdated Show resolved Hide resolved
src/multio/action/scale/Mapping.cc Outdated Show resolved Hide resolved
@dsarmany dsarmany force-pushed the feature/scaling-action branch from 2427724 to d61694d Compare November 27, 2024 13:51
@dsarmany dsarmany merged commit 6ef0689 into develop Nov 27, 2024
126 checks passed
@dsarmany dsarmany deleted the feature/scaling-action branch November 27, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants