Skip to content

Commit

Permalink
Revert "Updating from main (#548)"
Browse files Browse the repository at this point in the history
This reverts commit 3df403d.
  • Loading branch information
anirban-chaudhuri committed Mar 21, 2024
1 parent bb26d94 commit 90cf34a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 56 deletions.
9 changes: 1 addition & 8 deletions pyciemss/compiled_dynamics.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions pyciemss/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 1 addition & 21 deletions tests/test_compiled_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
11 changes: 0 additions & 11 deletions tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
MAPPING_FOR_DATA_TESTS,
MODEL_URLS,
MODELS,
MODELS_WITHOUT_DISTRIBUTIONS,
NON_POS_INTS,
NUM_SAMPLES,
OPT_MODELS,
Expand Down Expand Up @@ -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,
)

0 comments on commit 90cf34a

Please sign in to comment.