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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.97%. Comparing base (000e688) to head (37dfc43).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #464      +/-   ##
==========================================
+ Coverage   91.04%   91.97%   +0.92%     
==========================================
  Files          55       56       +1     
  Lines        2636     2578      -58     
  Branches      144      144              
==========================================
- Hits         2400     2371      -29     
+ Misses        163      132      -31     
- Partials       73       75       +2     

☔ 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?

@slayoo
Copy link
Member

slayoo commented Jan 15, 2026

@jcurtis2, CI is now fixed here.

Codecov detects two missing lines, which are a bit puzzling, but potentially seem to be a pair of important misses:

image

and

image

@jcurtis2 jcurtis2 marked this pull request as ready for review January 16, 2026 15:29
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