-
Notifications
You must be signed in to change notification settings - Fork 38
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
cppcore: implement memoization once for all features #323
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #323 +/- ##
==========================================
+ Coverage 55.65% 57.39% +1.73%
==========================================
Files 29 29
Lines 8046 7820 -226
Branches 3423 3235 -188
==========================================
+ Hits 4478 4488 +10
+ Misses 955 847 -108
+ Partials 2613 2485 -128
☔ View full report in Codecov by Sentry. |
0782e88
to
da0e37e
Compare
efel/cppcore/cfeature.h
Outdated
vector<double>& getmapDoubleData(string strName); | ||
|
||
template <typename T> | ||
const vector<T> getMapData(const string& strName, const map<string, vector<T>>& mapData) { |
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.
Not very familiar with c++ good practices, but shouldn't these three functions be in cfeature.cpp? With just their name declaration here in cfeature.h?
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.
Good point. Let me do it that way to be consistent with the rest of the methods of cFeature
.
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.
Done in the last commit. Now the header file looks neat.
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.
great, thank you!
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.
Well done!
Part of #321.
Memoization previously was done n_features times hence it was very hard to test.
There are ~150 C++ features. Each was performing a separate checking and retrieval of the cached results. Now there is only one implementation.
The responsibility of memoization is moved to cfeature. It became testable.
Does not introduce behavioural changes.
Scientists writing features (or reading them) do not have to worry about the underlying memoization mechanisms.
Uses C++17 for the
if constexpr (std::is_same_v<T, int>)
that allows conditional compilation of templates.Note: CI image is updated to become ubuntu-22.04 since it uses gcc-11 by default. Otherwise we have to explicitly install gcc-11in each ci task. This change does not affect the users installing the wheels. They don't need to have a C++17 capable compiler. They'll be using the pre-compiled binaries we provide in the wheels.