BDI-pathogens / OpenABM-Covid19

OpenABM-Covid19: an agent-based model for modelling the spread of SARS-CoV-2 (coronavirus) and control interventions for the Covid-19 epidemic
GNU General Public License v3.0
111 stars 76 forks source link

Adjust test calls to use Python interface #234

Closed p-robot closed 1 year ago

p-robot commented 1 year ago

Adjusted main test files to call the Python interface instead of the C executable. This removes any calls of subprocess module. This is in reference to issue #146.

Some minor formatting of tests also included in these commits.

Outstanding tests are those in tests/test_infection_dynamics.py and conftest.py. These will be amended in a future commit (as they require a more involved restructure as they have functions that pass parameter objects etc).

roberthinch commented 1 year ago

Good job removing all the very old ways of calling the model.

We could go one step further and remove all file calls completely (this is what I do with the R interface, although I've implemented for the Python interface as well). Look at /src/COVID19/model.pywhere you can use:

import COVID19.model as abm
 model = abm.Model( params = { "n_total" : 10000, "end_time": 20 } )
 model.run()

Where params is a dictionary of overrides to the default parameters.

You also have:

model.get_individuals()
model.get_transmissions()

which directly returns dataframes from the C model object as opposed to going via files.

I've not yet implemented for the interactions (probably worth doing) or trace tokens (probably not worth doing).