Skip to content

Commit

Permalink
Merge pull request #128 from marshall-lab/develop
Browse files Browse the repository at this point in the history
Deploy floating point fix, random trial enrolled
  • Loading branch information
mcmcgrath13 authored Oct 16, 2020
2 parents af390f6 + bfd032a commit beb5b2f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TITAN Simulation

[![DOI](https://zenodo.org/badge/80315242.svg)](https://zenodo.org/badge/latestdoi/80315242)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/marshall-lab/TITAN)](https://github.com/marshall-lab/TITAN/releases/latest/) [![](https://github.com/marshall-lab/TITAN/workflows/Unit%20Tests/badge.svg)](https://github.com/marshall-lab/TITAN/actions) [![codecov](https://codecov.io/gh/marshall-lab/TITAN/branch/develop/graph/badge.svg?token=wjkExshhyh)](https://codecov.io/gh/marshall-lab/TITAN) [![GitHub](https://img.shields.io/github/license/marshall-lab/TITAN)](https://github.com/marshall-lab/TITAN/blob/develop/LICENSE) [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://marshall-lab.github.io/TITAN/)

TITAN (Treatment of Infectious Transmissions through Agent-based Network) is an agent-based simulation model used to explore contact transmission in complex social networks. Starting with the initializing agent population, TITAN iterates over a series of stochastic interactions where agents can interact with one another, transmit infections through various medium, and enter and exit the care continuum. The purpose of TITAN is to evaluate the impact of prevention and treatment models on incidence and prevalence rates of the targeted disease(s) through the use of data fitting simulated trajectories and rich statistics of primary/sub-population attributable proportions.
Expand Down
4 changes: 2 additions & 2 deletions run_titan.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def drange(start, stop, step):
while r < stop:
yield r
r += step
r = round(r, 3)
r = round(r, 6)


def setup_sweeps(sweeps):
Expand Down Expand Up @@ -184,7 +184,7 @@ def setup_sweeps_file(sweepfile, rows):
val = int(v)
except ValueError:
try:
val = float(v)
val = round(float(v), 6)
except ValueError:
raise ValueError(
"sweep values must be numbers (int or float)"
Expand Down
2 changes: 1 addition & 1 deletion tests/params/basic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
demographics:
black:
ppl: 0.6
ppl: 0.600000000000567
MSM:
ppl: 0.3
drug_type:
Expand Down
3 changes: 1 addition & 2 deletions tests/params/setting_params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ partnership:
sex:
acquisition:
MSM:
insertive: 0.0011

insertive: 0.0011000000000001
4 changes: 3 additions & 1 deletion tests/parse_params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def test_create_params_base(tmpdir):
assert "white" not in params.classes.races
assert params.partnership.sex.acquisition.MSM.versatile == 0.00745 # from setting
assert params.partnership.sex.acquisition.MSM.receptive == 0.0138 # from base
assert params.partnership.sex.acquisition.MSM.insertive == 0.0011 # from param
assert (
params.partnership.sex.acquisition.MSM.insertive == 0.0011
) # from param, rounded


@pytest.mark.unit
Expand Down
2 changes: 1 addition & 1 deletion titan/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ def initialize_random_trial(self):
for ag in comp.nodes():
ag.random_trial_enrolled = True
if not ag.hiv and not ag.prep:
ag.intervention_ever = True
if (
self.run_random.random()
< ag.location.params.prep.target
and not ag.vaccine
):
self.initiate_prep(ag, force=True)
ag.intervention_ever = True
elif self.params.prep.pca.choice == "eigenvector":
centrality = nx.algorithms.centrality.eigenvector_centrality(comp)
assert len(centrality) >= 1, "Empty centrality"
Expand Down
4 changes: 4 additions & 0 deletions titan/parse_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def check_item(val, d, key_path, keys=None, pops=None):
if d["type"] == "float":
if isinstance(val, int):
val = float(val)

# avoid floating point errors by making numbers more reasonable
val = round(val, 6)

assert isinstance(val, float), f"{val} must be a float [{key_path}]"
if d["type"] == "boolean":
assert isinstance(val, bool), f"{val} must be a bool [{key_path}]"
Expand Down

0 comments on commit beb5b2f

Please sign in to comment.