Skip to content
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

Remove deprecated AddExposures method. #102

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class TracingRiskScore : public RiskScore {
infection_onset_time_ = std::min(infection_onset_time_, transition.time);
}
}
void AddExposures(absl::Span<const Exposure* const> exposures) override {}
void AddExposureNotification(const Exposure& exposure,
const ContactReport& notification) override {
// We don't take action on negative tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class TogglingRiskScore : public RiskScore {
: location_type_(std::move(location_type)), toggles_(toggles) {}

void AddHealthStateTransistion(HealthTransition transition) override {}
void AddExposures(absl::Span<const Exposure* const> exposures) override {}
void AddExposureNotification(const Exposure& exposure,
const ContactReport& notification) override {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class LearningRiskScore : public RiskScore {
infection_onset_time_ = std::min(infection_onset_time_, transition.time);
}
}
void AddExposures(absl::Span<const Exposure* const> exposures) override {}
void AddExposureNotification(const Exposure& exposure,
const ContactReport& notification) override {
// Actuate based on app user flag.
Expand Down Expand Up @@ -176,11 +175,6 @@ class AppEnabledRiskScore : public RiskScore {
void AddHealthStateTransistion(HealthTransition transition) override {
risk_score_->AddHealthStateTransistion(transition);
}
void AddExposures(absl::Span<const Exposure* const> exposures) override {
if (is_app_enabled_) {
risk_score_->AddExposures(exposures);
}
}
void AddExposureNotification(const Exposure& exposure,
const ContactReport& notification) override {
if (is_app_enabled_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,12 @@ TEST_F(RiskScoreTest, GetsContactRetentionDuration) {

TEST_F(RiskScoreTest, AppEnabledRiskScoreTogglesBehaviorOn) {
auto risk_score = absl::make_unique<MockRiskScore>();
EXPECT_CALL(*risk_score, AddExposures).Times(1);
EXPECT_CALL(*risk_score, AddExposureNotification).Times(1);
EXPECT_CALL(*risk_score, GetContactTracingPolicy)
.WillOnce(testing::Return(RiskScore::ContactTracingPolicy{
.report_recursively = false, .send_report = true}));
auto app_enabled_risk_score = CreateAppEnabledRiskScore(
/*is_app_enabled=*/true, std::move(risk_score));
app_enabled_risk_score->AddExposures({});
app_enabled_risk_score->AddExposureNotification({}, {});
EXPECT_THAT(app_enabled_risk_score->GetContactTracingPolicy(
Timestep(TimeFromDay(21), absl::Hours(24))),
Expand All @@ -324,12 +322,10 @@ TEST_F(RiskScoreTest, AppEnabledRiskScoreTogglesBehaviorOn) {

TEST_F(RiskScoreTest, AppEnabledRiskScoreTogglesBehaviorOff) {
auto risk_score = absl::make_unique<MockRiskScore>();
EXPECT_CALL(*risk_score, AddExposures).Times(0);
EXPECT_CALL(*risk_score, AddExposureNotification).Times(0);
EXPECT_CALL(*risk_score, GetContactTracingPolicy).Times(0);
auto app_enabled_risk_score = CreateAppEnabledRiskScore(
/*is_app_enabled=*/false, std::move(risk_score));
app_enabled_risk_score->AddExposures({});
app_enabled_risk_score->AddExposureNotification({}, {});
EXPECT_THAT(app_enabled_risk_score->GetContactTracingPolicy(
Timestep(TimeFromDay(21), absl::Hours(24))),
Expand Down
1 change: 0 additions & 1 deletion agent_based_epidemic_sim/core/risk_score.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace {
class NullRiskScore : public RiskScore {
public:
void AddHealthStateTransistion(HealthTransition transition) override {}
void AddExposures(absl::Span<const Exposure* const> exposures) override {}
void AddExposureNotification(const Exposure& contact,
const ContactReport& notification) override {}

Expand Down
2 changes: 0 additions & 2 deletions agent_based_epidemic_sim/core/risk_score.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class RiskScore {
public:
// Informs the RiskScore of a HealthTransition.
virtual void AddHealthStateTransistion(HealthTransition transition) = 0;
// Informs the RiskScore of new exposures.
virtual void AddExposures(absl::Span<const Exposure* const> exposures) = 0;
// Informs the RiskScore of received exposure notifications.
virtual void AddExposureNotification(const Exposure& exposure,
const ContactReport& notification) = 0;
Expand Down
1 change: 0 additions & 1 deletion agent_based_epidemic_sim/core/seir_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ void SEIRAgent::ProcessInfectionOutcomes(
for (const InfectionOutcome& infection_outcome : infection_outcomes) {
exposures.push_back(&infection_outcome.exposure);
}
risk_score_->AddExposures(exposures);

if (next_health_transition_.health_state == HealthState::SUSCEPTIBLE &&
!exposures.empty()) {
Expand Down
15 changes: 0 additions & 15 deletions agent_based_epidemic_sim/core/seir_agent_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,6 @@ TEST(SEIRAgentTest,
EXPECT_CALL(*risk_score, GetContactTracingPolicy(_))
.WillOnce(Return(RiskScore::ContactTracingPolicy{}));

// This is a key assertion that we pass on exposures from
// ProcessInfectionOutcomes to the risk score.
EXPECT_CALL(*risk_score, AddExposures(testing::ElementsAre(
&outcomes[0].exposure, &outcomes[1].exposure)));

// This is a key assertion that we do pass on contact reports to the
// risk score.
// Only the contact_report form agents 12 and 15 are reported because the
Expand Down Expand Up @@ -528,8 +523,6 @@ TEST(SEIRAgentTest, PositiveTest) {
}};
std::vector<InfectionOutcome> outcomes =
OutcomesFromContacts(kUuid, contacts);
EXPECT_CALL(*risk_score,
AddExposures(testing::ElementsAre(&outcomes[0].exposure)));

EXPECT_CALL(*transition_model, GetNextHealthTransition(transition))
.WillOnce(
Expand Down Expand Up @@ -590,8 +583,6 @@ TEST(SEIRAgentTest, NegativeTestResult) {
.health_state = HealthState::SUSCEPTIBLE}));
std::vector<InfectionOutcome> outcomes =
OutcomesFromContacts(kUuid, contacts);
EXPECT_CALL(*risk_score,
AddExposures(testing::ElementsAre(&outcomes[0].exposure)));
EXPECT_CALL(*risk_score, AddExposureNotification(contacts[0].exposure,
contact_reports[0]));

Expand Down Expand Up @@ -627,9 +618,6 @@ TEST(SEIRAgentTest, SendContactReports) {
auto contact_report_broker = absl::make_unique<MockBroker<ContactReport>>();

auto risk_score = absl::make_unique<MockRiskScore>();
// That we add exposures to the risk score is tested elsewhere so we ignore it
// in this test.
EXPECT_CALL(*risk_score, AddExposures(_)).Times(testing::AnyNumber());
EXPECT_CALL(*risk_score, ContactRetentionDuration)
.WillRepeatedly(Return(absl::Hours(24 * 7)));
EXPECT_CALL(*risk_score, GetContactTracingPolicy(_))
Expand Down Expand Up @@ -818,9 +806,6 @@ TEST(SEIRAgentTest, SendContactReportsBeforeAndAfterSymptoms) {
auto contact_report_broker = absl::make_unique<MockBroker<ContactReport>>();

auto risk_score = absl::make_unique<MockRiskScore>();
// That we add exposures to the risk score is tested elsewhere so we ignore it
// in this test.
EXPECT_CALL(*risk_score, AddExposures(_)).Times(testing::AnyNumber());
EXPECT_CALL(*risk_score, ContactRetentionDuration)
.WillRepeatedly(Return(absl::Hours(24 * 7)));
EXPECT_CALL(*risk_score, GetContactTracingPolicy(_))
Expand Down
2 changes: 0 additions & 2 deletions agent_based_epidemic_sim/util/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class MockRiskScore : public RiskScore {
public:
MOCK_METHOD(void, AddHealthStateTransistion, (HealthTransition transition),
(override));
MOCK_METHOD(void, AddExposures, (absl::Span<const Exposure* const> exposures),
(override));
MOCK_METHOD(void, AddExposureNotification,
(const Exposure& contact, const ContactReport& notification),
(override));
Expand Down