Skip to content

Conversation

@jcurtis2
Copy link
Member

Attempting to simplify code by introducing templates for setting and getting of attributes and derived values.

@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 98.11321% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.23%. Comparing base (f924d65) to head (70f8202).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/aero_mode.hpp 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #464      +/-   ##
==========================================
+ Coverage   91.04%   91.23%   +0.19%     
==========================================
  Files          55       56       +1     
  Lines        2636     2591      -45     
  Branches      144      144              
==========================================
- Hits         2400     2364      -36     
+ Misses        163      154       -9     
  Partials       73       73              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jcurtis2 jcurtis2 self-assigned this Nov 24, 2025
@Griger5
Copy link
Collaborator

Griger5 commented Nov 24, 2025

Maybe it would be beneficial to "abstract" the templates even more? get_value and set_value look the same in env_state.hpp and aero_particle.hpp. Maybe we could do something like this in a separate header (named getters.hpp ?):

namespace pypartmc { // possible namespace to avoid name conflicts

template <typename T, typename SelfType, typename Func>
inline T get_value(const SelfType &self, Func func) { // inline to keep it header-only
    T value{};
    func(self.ptr.f_arg(), &value);
    return value;
}

template <typename T, typename SelfType, typename Func>
inline void set_value(SelfType &self, Func func, T value) {
    func(self.ptr.f_arg_non_const(), &value);
}

}

And an example call would look like:

static auto get_height(const EnvState &self) {
     return pypartmc::get_value<double>(self, f_env_state_get_height);
}

The same could be considered for get_derived_value and get_derived_value_env_state. I'm not sure if these ones have a lot of uses in other classes, but even if they do not now, they could do in the future!

@slayoo slayoo changed the title Add templates for setters and getters Add templates for setters and getters; add temperature getter unit test for EnvState Dec 5, 2025
@slayoo
Copy link
Member

slayoo commented Dec 5, 2025

@jcurtis2, @Griger5, IIUC this is ready for merging, but could be extended with usage of the new templated setter and getters in other files, right?

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.

5 participants