-
Notifications
You must be signed in to change notification settings - Fork 62
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] Provide factory setup for creating models #1527
[ML] Provide factory setup for creating models #1527
Conversation
Move boilerplate code for creating models to a base class method. This goes some way to reducing duplicated code and standardizing how models are created.
this->makeModel(params, features, startTime); | ||
CCountingModel* modelNoGap = dynamic_cast<CCountingModel*>(m_Model.get()); | ||
BOOST_TEST_REQUIRE(modelNoGap); | ||
BOOST_REQUIRE_EQUAL(std::size_t(0), this->addPerson("p", m_Gatherer)); |
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.
BOOST_REQUIRE_EQUAL(std::size_t(0), this->addPerson("p", m_Gatherer)); | |
BOOST_REQUIRE_EQUAL(0, this->addPerson("p", m_Gatherer)); |
There's no need to cast expected types with Boost.Test. The places where we do this in existing code are a hangover from CppUnit.
this->makeModel(params, features, startTime); | ||
CCountingModel* modelNoGap = dynamic_cast<CCountingModel*>(m_Model.get()); | ||
BOOST_TEST_REQUIRE(modelNoGap); | ||
BOOST_REQUIRE_EQUAL(std::size_t(0), this->addPerson("p", m_Gatherer)); |
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.
BOOST_REQUIRE_EQUAL(std::size_t(0), this->addPerson("p", m_Gatherer)); | |
BOOST_REQUIRE_EQUAL(0, this->addPerson("p", m_Gatherer)); |
BOOST_REQUIRE_EQUAL(std::size_t(0), this->addPerson("p1", m_Gatherer)); | ||
BOOST_REQUIRE_EQUAL(std::size_t(1), this->addPerson("p2", m_Gatherer)); |
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.
BOOST_REQUIRE_EQUAL(std::size_t(0), this->addPerson("p1", m_Gatherer)); | |
BOOST_REQUIRE_EQUAL(std::size_t(1), this->addPerson("p2", m_Gatherer)); | |
BOOST_REQUIRE_EQUAL(0, this->addPerson("p1", m_Gatherer)); | |
BOOST_REQUIRE_EQUAL(1, this->addPerson("p2", m_Gatherer)); |
CEventRateModel* modelNoGap = dynamic_cast<CEventRateModel*>(modelNoGap_.get()); | ||
for (std::size_t i = 0u; i < 2; ++i) { | ||
BOOST_REQUIRE_EQUAL( | ||
std::size_t(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.
std::size_t(i), | |
i, |
model.reset(m_Factory->makeModel({gatherer})); | ||
BOOST_TEST_REQUIRE(model); | ||
BOOST_REQUIRE_EQUAL(model_t::E_EventRateOnline, model->category()); | ||
BOOST_REQUIRE_EQUAL(params.s_BucketLength, model->bucketLength()); | ||
for (std::size_t i = 0u; i < numberPeople; ++i) { | ||
BOOST_REQUIRE_EQUAL( | ||
std::size_t(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.
std::size_t(i), | |
i, |
CEventRateModel* modelWithGap = dynamic_cast<CEventRateModel*>(modelWithGap_.get()); | ||
for (std::size_t i = 0u; i < 2; ++i) { | ||
BOOST_REQUIRE_EQUAL( | ||
std::size_t(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.
std::size_t(i), | |
i, |
|
||
protected: | ||
using TInterimBucketCorrectorPtr = std::shared_ptr<ml::model::CInterimBucketCorrector>; | ||
using TModelFactoryPtr = boost::shared_ptr<ml::model::CModelFactory>; |
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.
Why is this using boost::shared_ptr
? If there's a good reason, e.g. it's used with some other Boost library that has boost::shared_ptr
in its interface, please add a comment.
* remove unnecessary type conversions from * replace boost constructs with standard library equivalents
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
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.
LGTM2
Move boilerplate code for creating models to a base class method. This goes some way to reducing duplicated code and standardizing how models are created in the tests.
Move boilerplate code for creating models to a base class method.
This goes some way to reducing duplicated code and standardising how models are created.
Relates to #1477