diff --git a/pyciemss/compiled_dynamics.py b/pyciemss/compiled_dynamics.py index ddcebd45b..8e7f53e3d 100644 --- a/pyciemss/compiled_dynamics.py +++ b/pyciemss/compiled_dynamics.py @@ -1,7 +1,7 @@ from __future__ import annotations import functools -from typing import Callable, Dict, List, Optional, Tuple, TypeVar, Union +from typing import Callable, Dict, Optional, Tuple, TypeVar, Union import mira import mira.metamodel @@ -39,13 +39,6 @@ def __init__(self, src, **kwargs): self.instantiate_parameters() - def params_with_distributions(self) -> List: - return [ - get_name(k) - for k, v in _compile_param_values(self.src).items() - if isinstance(v, pyro.nn.PyroSample) - ] - @pyro.nn.pyro_method def deriv(self, X: State[torch.Tensor]) -> None: return eval_deriv(self.src, self, X) diff --git a/pyciemss/interfaces.py b/pyciemss/interfaces.py index 9adf72bfc..2d6a9e579 100644 --- a/pyciemss/interfaces.py +++ b/pyciemss/interfaces.py @@ -648,12 +648,6 @@ def calibrate( model = CompiledDynamics.load(model_path_or_json) - if len(model.params_with_distributions()) == 0: - raise ValueError( - "The model does not contain distributions representing uncertainty over any parameters." - "As there is no uncertainty, `calibrate` will not update any parameters." - ) - data_timepoints, data = load_data(data_path, data_mapping=data_mapping) # Check that num_iterations is a positive integer diff --git a/tests/fixtures.py b/tests/fixtures.py index ac107dcdc..50ab66f0d 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -85,16 +85,6 @@ def __init__( ModelFixture(os.path.join(MODELS_PATH, "SEIRHD_stockflow.json"), "p_cbeta"), ] -MODELS_WITHOUT_DISTRIBUTIONS = [ - ModelFixture( - os.path.join(MODELS_PATH, "SEIR_stockflow_no_uncertainty"), - "p_cbeta", - os.path.join(DATA_PATH, "traditional.csv"), - {"Infected": "I"}, - False, - ), -] - optimize_kwargs_SIRstockflow_param = { "qoi": lambda x: obs_nday_average_qoi(x, ["I_state"], 1), "risk_bound": 300.0, diff --git a/tests/test_compiled_dynamics.py b/tests/test_compiled_dynamics.py index d859e05df..a465d9d96 100644 --- a/tests/test_compiled_dynamics.py +++ b/tests/test_compiled_dynamics.py @@ -8,13 +8,7 @@ from pyciemss.compiled_dynamics import CompiledDynamics -from .fixtures import ( - END_TIMES, - MODEL_URLS, - MODELS_WITHOUT_DISTRIBUTIONS, - START_TIMES, - check_is_state, -) +from .fixtures import END_TIMES, MODEL_URLS, START_TIMES, check_is_state @pytest.mark.parametrize("url", MODEL_URLS) @@ -61,17 +55,3 @@ def test_compiled_dynamics_load_json(url, start_time, end_time): with TorchDiffEq(): simulation = model(torch.as_tensor(start_time), torch.as_tensor(end_time)) check_is_state(simulation, torch.Tensor) - - -@pytest.mark.parametrize("url", MODEL_URLS) -def test_params_with_distributions(url): - model = CompiledDynamics.load(url) - assert isinstance(model, CompiledDynamics) - assert len(model.params_with_distributions()) > 0 - - -@pytest.mark.parametrize("models", MODELS_WITHOUT_DISTRIBUTIONS) -def test_params_without_distributions(models): - model = CompiledDynamics.load(models.url) - assert isinstance(model, CompiledDynamics) - assert len(model.params_with_distributions()) == 0 diff --git a/tests/test_interfaces.py b/tests/test_interfaces.py index 0a39b7a6b..8bd270021 100644 --- a/tests/test_interfaces.py +++ b/tests/test_interfaces.py @@ -21,7 +21,6 @@ MAPPING_FOR_DATA_TESTS, MODEL_URLS, MODELS, - MODELS_WITHOUT_DISTRIBUTIONS, NON_POS_INTS, NUM_SAMPLES, OPT_MODELS, @@ -698,13 +697,3 @@ def test_bad_euler_solver_optimize(model_fixture): logging_step_size, **optimize_kwargs, ) - - -@pytest.mark.parametrize("model_fixture", MODELS_WITHOUT_DISTRIBUTIONS) -def test_calibrate_no_distributions(model_fixture): - with pytest.raises(ValueError): - calibrate( - model_fixture.url, - model_fixture.data_path, - data_mapping=model_fixture.data_mapping, - )