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

Cleaned up basic-infection. Fixes #239. #274

Open
wants to merge 2 commits into
base: main
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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ assert_cmd = "^2.0.16"
criterion = "^0.5.1"

# Example Libraries
ixa_example_basic_infection = { path = "examples/basic-infection" }
ixa_example_births_deaths = { path = "examples/births-deaths" }

[lints.clippy]
Expand Down
28 changes: 26 additions & 2 deletions benches/example_basic_infection/example_basic_infection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
pub mod incidence_report;
pub mod infection_manager;
pub mod people;
pub mod transmission_manager;

use criterion::{criterion_group, criterion_main, Criterion};
use ixa::Context;
use ixa_example_basic_infection::initialize;
use ixa::{Context, ContextRandomExt};

static POPULATION: u64 = 1000;
static SEED: u64 = 123;
static MAX_TIME: f64 = 303.0;
static FOI: f64 = 0.1;
static INFECTION_DURATION: f64 = 5.0;

pub fn initialize(context: &mut Context) {
context.init_random(SEED);

people::init(context);
transmission_manager::init(context);
infection_manager::init(context);
incidence_report::init(context).unwrap_or_else(|e| {
eprintln!("failed to init incidence_report: {e}");
});
context.add_plan(MAX_TIME, |context| {
context.shutdown();
});
}

pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("example basic-infection", |bencher| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn handle_infection_status_change(context: &mut Context, event: InfectionStatusE
});
}

#[allow(clippy::missing_errors_doc)]
pub fn init(context: &mut Context) -> Result<(), IxaError> {
trace!("Initializing incidence_report");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub fn init(context: &mut Context) {

#[cfg(test)]
mod test {
#![allow(clippy::all)] // False positives
#![allow(unused_imports)] // False positives
use crate::infection_manager::InfectionStatusEvent;
use crate::people::InfectionStatus;
use crate::people::InfectionStatusValue;
Expand All @@ -57,6 +59,7 @@ mod test {

define_data_plugin!(RecoveryPlugin, usize, 0);

#[allow(dead_code)] // False positive
fn handle_recovery_event(context: &mut Context, event: InfectionStatusEvent) {
if event.current == InfectionStatusValue::R {
*context.get_data_container_mut(RecoveryPlugin) += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define_person_property_with_default!(
);

/// Populates the "world" with the `POPULATION` number of people.
#[allow(clippy::missing_panics_doc)]
pub fn init(context: &mut Context) {
trace!("Initializing people");
for _ in 0..POPULATION {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub fn init(context: &mut Context) {

#[cfg(test)]
mod test {
#![allow(clippy::all)] // False positives
#![allow(unused_imports)] // False positives
use super::*;
use crate::people::{InfectionStatus, InfectionStatusValue};
use crate::SEED;
Expand Down
1 change: 1 addition & 0 deletions docs/book/models/disease_model
20 changes: 0 additions & 20 deletions examples/basic-infection/Cargo.toml

This file was deleted.

Loading