-
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
added first pass at python features #43
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,3 +154,22 @@ def test_getFeature_non_existant(self): | |
"""cppcore: Testing failure exit code in getFeature""" | ||
import efel.cppcore | ||
efel.cppcore.getFeature("does_not_exist", list()) | ||
|
||
def test_registerFeature(self): | ||
import efel.cppcore | ||
|
||
def getTwiceAP_Amp(output): | ||
feature_values = list() | ||
efel.cppcore.getFeature('AP_amplitude', feature_values) | ||
output.extend(2*x for x in feature_values) | ||
return len(feature_values) | ||
|
||
self.setup_data() | ||
efel.cppcore.registerFeature('getTwiceAP_Amp', getTwiceAP_Amp) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would also need some mechanism to let different versions of the same feature live next to each other. Maybe we can add a version_string argument ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about just using the name of the feature do it: 'AP_amplitude_v1', 'AP_amplitude_v2', etc. That way, the calling convention doesn't have to change. Otherwise, getFeature has to take a version as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmm, that won't be general enough. The idea is that the user should be able to replace e.g. AP_amplitude with it's own version, 'and' that then every feature that depends on AP_amplitude will pick up the new implementation automatically. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok. Then, the idea would be that features can still depend on the old version if that's what their dependency says? That means we have to version all features, including the ones that already exist, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, but that's why we have the dependency file and the liibv* versions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, AP_amplitude wouldn't be overwritten for those, just for future ones? |
||
features = list() | ||
ret = efel.cppcore.getFeature('getTwiceAP_Amp', features) | ||
nt.ok_(isinstance(features[0], float)) | ||
nt.eq_(5, len(features)) | ||
nt.ok_(np.allclose(2 * np.array([80.45724099440199, 80.46320199354948, 80.73300299176428, | ||
80.9965359926715, 81.87292599493423]), | ||
features)) |
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.
This is how to use it
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 that ideally the feature should use setFeature to store it's own values
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.
That's mainly used as an internal cache, correct?
I could keep that local to cppcore.cpp, if that makes sense. What is the invalidation policy for the cache at the moment (so I can mirror it)?
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 100% sure, but I think that cppcore.Initialize resets the cache ?