From 3ec18411ce33f680173e110d2baa13a9cfb1aae2 Mon Sep 17 00:00:00 2001 From: IsaccBarker Date: Mon, 6 Jan 2025 20:50:28 -0700 Subject: [PATCH 1/5] [pypa] --- .gitignore | 7 +++++-- pyproject.toml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index af8247a..3644549 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,17 @@ .cache/ .ipynb_checkpoints/ .pytest_cache/ +.ropeproject/ +.nocheck/ _build/ build/ +dist/ __pycache__/ +src/epiworldpy.egg-info compile_commands.json + *.html *.ipynb -.nocheck/ - *_files !README_files diff --git a/pyproject.toml b/pyproject.toml index 7230841..7deb764 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["scikit-build-core>=0.3.3", "pybind11"] +requires = ["scikit-build-core>=0.10", "pybind11"] build-backend = "scikit_build_core.build" [project] name = "epiworldpy" -version = "0.0.1" +version = "0.0.4" description = "Python bindings for epiworld" readme = "README.md" requires-python = ">=3.7" From 0b8d3f98bcdc2e2d90c21c5ab50a6b1f4421fccf Mon Sep 17 00:00:00 2001 From: IsaccBarker Date: Tue, 14 Jan 2025 18:57:30 -0700 Subject: [PATCH 2/5] [tests] add more, fix #79 --- tests/test_basic.py | 2 +- tests/test_distribution.py | 13 +++++++ tests/test_entity.py | 30 ++++++++++++++++ tests/test_models.py | 73 ++++++++++---------------------------- tests/test_saver.py | 34 +++++++++--------- 5 files changed, 79 insertions(+), 73 deletions(-) create mode 100644 tests/test_distribution.py create mode 100644 tests/test_entity.py diff --git a/tests/test_basic.py b/tests/test_basic.py index a51982d..7a7ffa9 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,4 +1,4 @@ import epiworldpy as epiworld def test_version(): - assert epiworld.__version__ == "0.0.1" + assert epiworld.__version__ == "0.0.4" diff --git a/tests/test_distribution.py b/tests/test_distribution.py new file mode 100644 index 0000000..6e35643 --- /dev/null +++ b/tests/test_distribution.py @@ -0,0 +1,13 @@ +import epiworldpy as epiworld + +def test_distribution(): + hypothetical = epiworld.ModelSIR( + name = 'hypothetical', + prevalence = 0.01, + transmission_rate = 0.1, + recovery_rate = 0.14 + ) + + hypothetical.agents_smallworld(100000, 10, False, 0.01) + + hypothetical.run(100, 223) diff --git a/tests/test_entity.py b/tests/test_entity.py new file mode 100644 index 0000000..486a000 --- /dev/null +++ b/tests/test_entity.py @@ -0,0 +1,30 @@ +import epiworldpy as epiworld + +def dist_factory(start, end): + def entity_to_agent_fun(entity, model): + agents = model.get_agents() + + for i in range(start, end): + entity.add_agent(agents[i], model) + + return entity_to_agent_fun + +def test_entity(): + hypothetical = epiworld.ModelSIRCONN( + name = 'hypothetical', + n = 10000, + prevalence = 0.01, + contact_rate = 10, + transmission_rate = 0.1, + recovery_rate = 0.14 + ) + + entity_1 = epiworld.Entity("Entity 1", dist_factory(0, 3000)) + entity_2 = epiworld.Entity("Entity 2", dist_factory(3000, 6000)) + entity_3 = epiworld.Entity("Entity 3", dist_factory(6000, 10000)) + + hypothetical.add_entity(entity_1) + hypothetical.add_entity(entity_2) + hypothetical.add_entity(entity_3) + + hypothetical.run(100, 223) diff --git a/tests/test_models.py b/tests/test_models.py index 0ad0a93..7bf487b 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,75 +1,38 @@ import epiworldpy as epiworld -# TODO: Decide the right way to validate data; how often is the underlying C++ -# simulation code changed in a way that will change outputs here? What's the -# tradeoff? - -def test_diffnet_simple(): - # TODO: How do we invoke this model? - pass - -def test_seir_simple(): - # TODO: Implement `agents_from_adjlist` or something similar. - pass - def test_seirconn_simple(): - covid19 = epiworld.ModelSEIRCONN( - name = 'covid-19', + hypothetical = epiworld.ModelSEIRCONN( + name = 'hypothetical', n = 10000, - prevalence = .01, + prevalence = 0.01, contact_rate = 2.0, - transmission_rate = .1, + transmission_rate = 0.1, incubation_days = 7.0, recovery_rate = 0.14 ) - covid19.run(100, 223) - -def test_seird_simple(): - # TODO: Implement `agents_from_adjlist` or something similar. - pass - -def test_sir_simple(): - # TODO: Implement `agents_from_adjlist` or something similar. - pass + hypothetical.run(100, 223) def test_sirconn_simple(): - covid19 = epiworld.ModelSIRCONN( - name = 'covid-19', + hypothetical = epiworld.ModelSIRCONN( + name = 'hypothetical', n = 10000, - prevalence = .01, + prevalence = 0.01, contact_rate = 2.0, - transmission_rate = .1, + transmission_rate = 0.1, recovery_rate = 0.14 ) - covid19.run(100, 223) - -def test_sird_simple(): - # TODO: Implement `agents_from_adjlist` or something similar. - pass + hypothetical.run(100, 223) -def test_sirdconn_simple(): - covid19 = epiworld.ModelSIRDCONN( - name = 'covid-19', - n = 10000, - prevalence = .01, - contact_rate = 2.0, - transmission_rate = .1, - recovery_rate = 0.14, - death_rate = 0.1, +def test_smallworld(): + hypothetical = epiworld.ModelSIR( + name = 'hypothetical', + prevalence = 0.01, + transmission_rate = 0.1, + recovery_rate = 0.14 ) - covid19.run(100, 223) - -def test_sis_simple(): - # TODO: Implement `agents_from_adjlist` or something similar. - pass - -def test_sisd_simple(): - # TODO: Implement `agents_from_adjlist` or something similar. - pass + hypothetical.agents_smallworld(100000, 10, False, 0.01) -def test_surv_simple(): - # TODO: Implement `agents_from_adjlist` or something similar. - pass + hypothetical.run(100, 223) diff --git a/tests/test_saver.py b/tests/test_saver.py index a234b47..f092559 100644 --- a/tests/test_saver.py +++ b/tests/test_saver.py @@ -1,18 +1,18 @@ -import epiworldpy as epiworld +#import epiworldpy as epiworld -def test_saver_basic(): - covid19 = epiworld.ModelSEIRCONN( - name = 'covid-19', - n = 10000, - prevalence = .01, - contact_rate = 2.0, - transmission_rate = .1, - incubation_days = 7.0, - recovery_rate = 0.14 - ) - - saver = epiworld.Saver("total_hist", "virus_hist") - - saver.run_multiple(covid19, 100, 4, nthreads=1) - - # TODO: Verify things worked correctly, as is the point of tesing. +#def test_saver_basic(): +# covid19 = epiworld.ModelSEIRCONN( +# name = 'covid-19', +# n = 10000, +# prevalence = .01, +# contact_rate = 2.0, +# transmission_rate = .1, +# incubation_days = 7.0, +# recovery_rate = 0.14 +# ) +# +# saver = epiworld.Saver("total_hist", "virus_hist") +# +# saver.run_multiple(covid19, 100, 4, nthreads=1) +# +# # TODO: Verify things worked correctly, as is the point of tesing. From 0df350d0df0efce506b9b7896bf48d1ac616d8e2 Mon Sep 17 00:00:00 2001 From: IsaccBarker Date: Wed, 15 Jan 2025 16:03:40 -0700 Subject: [PATCH 3/5] Revert "[pypa]" This reverts commit 3ec18411ce33f680173e110d2baa13a9cfb1aae2. --- .gitignore | 7 ++----- pyproject.toml | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 3644549..af8247a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,14 @@ .cache/ .ipynb_checkpoints/ .pytest_cache/ -.ropeproject/ -.nocheck/ _build/ build/ -dist/ __pycache__/ -src/epiworldpy.egg-info compile_commands.json - *.html *.ipynb +.nocheck/ + *_files !README_files diff --git a/pyproject.toml b/pyproject.toml index 7deb764..7230841 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["scikit-build-core>=0.10", "pybind11"] +requires = ["scikit-build-core>=0.3.3", "pybind11"] build-backend = "scikit_build_core.build" [project] name = "epiworldpy" -version = "0.0.4" +version = "0.0.1" description = "Python bindings for epiworld" readme = "README.md" requires-python = ">=3.7" From 5470fce1bd6bb8df7a827c04d63abdb4f058cfaa Mon Sep 17 00:00:00 2001 From: Milo Banks Date: Tue, 21 Jan 2025 16:35:18 -0700 Subject: [PATCH 4/5] [revert] Revert to main. --- tests/test_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index 7a7ffa9..a51982d 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,4 +1,4 @@ import epiworldpy as epiworld def test_version(): - assert epiworld.__version__ == "0.0.4" + assert epiworld.__version__ == "0.0.1" From 13824cf6d57097c72b7a7728fef8b05fcb57ff2f Mon Sep 17 00:00:00 2001 From: Milo Banks Date: Tue, 21 Jan 2025 16:36:00 -0700 Subject: [PATCH 5/5] [saver] delete tests --- tests/test_saver.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 tests/test_saver.py diff --git a/tests/test_saver.py b/tests/test_saver.py deleted file mode 100644 index f092559..0000000 --- a/tests/test_saver.py +++ /dev/null @@ -1,18 +0,0 @@ -#import epiworldpy as epiworld - -#def test_saver_basic(): -# covid19 = epiworld.ModelSEIRCONN( -# name = 'covid-19', -# n = 10000, -# prevalence = .01, -# contact_rate = 2.0, -# transmission_rate = .1, -# incubation_days = 7.0, -# recovery_rate = 0.14 -# ) -# -# saver = epiworld.Saver("total_hist", "virus_hist") -# -# saver.run_multiple(covid19, 100, 4, nthreads=1) -# -# # TODO: Verify things worked correctly, as is the point of tesing.