-
Notifications
You must be signed in to change notification settings - Fork 66
[ML] Move model test helper functions to base class #1523
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
[ML] Move model test helper functions to base class #1523
Conversation
Move existing model test helper functions to base class and share functionality where possible.
|
|
||
| namespace { | ||
|
|
||
| const std::string EMPTY_STRING; |
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 in an unnamed namespace in several of the files. Could it be made a public or protected static constant on the test fixture? Then it would still be usable in the tests without qualification, but wouldn't be duplicated.
tveasey
left a comment
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.
Overall looks good. I made a few minor comments and also wonder if we can pull one more bit of functionality up to the base class.
| CEventData makeEventData(core_t::TTime time, | ||
| std::size_t pid, | ||
| double value, | ||
| const TOptionalStr& influence = TOptionalStr()) { |
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 it should be possible to move this into the base class. We have makeEventData in CEventRateModelTest which I think this could be combined with.
| << ml::core::CContainerPrinter::print(orderedAnomalies)); | ||
| } | ||
|
|
||
| void CModelTestFixtureBase::generateAndCompareKey(const ml::model::function_t::TFunctionVec& countFunctions, |
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 seems like it should be static.
|
|
||
| int detectorIndex{0}; | ||
| for (const auto& countFunction : countFunctions) { | ||
| for (bool usingNull : useNull) { |
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.
Probably just moved here, but this can be more concise:
| for (bool usingNull : useNull) { | |
| for (bool usingNull : {true, false}) { |
then delete useNull. Similar for others below.
| for (std::size_t i = 0u; i < values.size(); ++i) { | ||
| processBucket(time, bucketLength, values[i], influencers[i], *gatherer, | ||
| m_ResourceMonitor, model, annotatedProbability); | ||
| processBucket(time, bucketLength, values[i], influencers[i], |
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.
For consistency it feels like all the calls to processBucket should be qualified (it's our usual style and you've done it for the other methods you've added):
| processBucket(time, bucketLength, values[i], influencers[i], | |
| this->processBucket(time, bucketLength, values[i], influencers[i], |
tveasey
left a comment
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.
LGTM
Move existing model test helper functions to base class and share functionality where possible.
Move existing model test helper functions to base class and share functionality where possible.
While this goes some way to reducing code duplication there may still be scope to
Relates to #1477