-
Notifications
You must be signed in to change notification settings - Fork 40
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
add mechanics for retrieving filter properties. #2693
base: develop
Are you sure you want to change the base?
Conversation
will add the C version of this soon to this PR |
Fixes #2669 |
@phlptp are you wanting a review on this? |
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.
It would be nice to return more meaningful errors.
void FilterOperations::set(std::string_view /*property*/, double /*val*/) {} | ||
void FilterOperations::setString(std::string_view /*property*/, std::string_view /*val*/) {} | ||
|
||
double FilterOperations::getProperty(std::string_view /*property*/) | ||
{ | ||
return invalidDouble; |
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.
Any reason this shouldn't just error?
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.
Then we have to do a bunch of error checking through a lot of calls.
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'm not a big fan of reusing two doubles named param1 and param2, and this definitely goes against the spirit of the linter here. Any way we can use a tagged union or std::variant instead? Might be helpful in the if statements too.
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.
the parameters have different meanings depending on which random distribution is used, so there is no standard naming convention there.
@@ -273,13 +350,45 @@ void RerouteFilterOperation::setString(std::string_view property, std::string_vi | |||
} | |||
catch (const std::regex_error& re) { | |||
std::cerr << "filter expression is not a valid Regular expression " << re.what() | |||
<< std::endl; | |||
<< '\n'; |
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.
Is this to avoid flushing cerr
?
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 cerr is flushed anyway, so I don't think the flushing matters here.
@josephmckinsey, can you get the C-based additions @phlptp just added into PyHELICS for testing? I don't know if we want to use the libclang script or do it manually. Maybe @nightlark has an idea on the best way to do this? |
For pyhelics changes: use https://github.com/GMLC-TDC/cheader2json#usage to dump ast.json files for the previous helics release (using the helics.h backup header file) and for the new development version of helics (using the new helics.h backup header file), then use it to do a diff of the ast.json files to get the changes that need to be made to pyhelics. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
7191f81
to
f90733b
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
||
/** get a property from a filter | ||
@param property the name of the property of the filter to change | ||
@param val the numerical value of the property |
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.
@param val the numerical value of the property |
@@ -51,6 +51,19 @@ class FilterOperations { | |||
@param val the numerical value of the property | |||
*/ | |||
virtual void setString(std::string_view property, std::string_view val); | |||
|
|||
/** get a property from a filter | |||
@param property the name of the property of the filter to change |
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.
@param property the name of the property of the filter to change | |
@param property the name of the property of the filter to get |
*/ | ||
virtual double getProperty(std::string_view property); | ||
/** get a string property on a filter | ||
@param property the name of the property of the filter to change |
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.
@param property the name of the property of the filter to change | |
@param property the name of the property of the filter to get |
virtual double getProperty(std::string_view property); | ||
/** get a string property on a filter | ||
@param property the name of the property of the filter to change | ||
@param val the numerical value of the property |
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.
@param val the numerical value of the property |
@@ -84,6 +84,17 @@ class HELICS_CXX_EXPORT Filter: public Interface { | |||
*/ | |||
virtual void setString(std::string_view property, std::string_view val); | |||
|
|||
/** get a string property on a filter | |||
@param property the name of the property of the filter to change |
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.
@param property the name of the property of the filter to change | |
@param property the name of the property of the filter to get |
* Get a double property from a filter | ||
* | ||
* @param filt The filter to modify. | ||
* @param prop A string containing the property to set. |
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.
* @param prop A string containing the property to set. | |
* @param prop A string containing the property to get. |
* Set a string property on a filter. The string output memory is valid until a subsequent call to to getPropertyString on the particular | ||
filter | ||
* | ||
* @param filt The filter to modify. |
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.
* @param filt The filter to modify. | |
* @param filt The filter to retrieve a value from. |
filter | ||
* | ||
* @param filt The filter to modify. | ||
* @param prop A string containing the property to set. |
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.
* @param prop A string containing the property to set. | |
* @param prop A string containing the property to get. |
HELICS_EXPORT double helicsFilterGetPropertyDouble(HelicsFilter filt, const char* prop); | ||
|
||
/** | ||
* Set a string property on a filter. The string output memory is valid until a subsequent call to to getPropertyString on the particular |
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.
* Set a string property on a filter. The string output memory is valid until a subsequent call to to getPropertyString on the particular | |
* Get a string property on a filter. The string output memory is valid until a subsequent call to getPropertyString on the particular |
|
||
/** | ||
* Set a string property on a filter. The string output memory is valid until a subsequent call to to getPropertyString on the particular | ||
filter |
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.
filter | |
filter. |
Any update on getting these changes into PyHELICS for testing? |
Summary
If merged this pull request will add mechanics for getting filter properties
Proposed changes