Skip to content

Commit

Permalink
test(model): adjust tests for sir model
Browse files Browse the repository at this point in the history
  • Loading branch information
emptymalei committed Jan 4, 2025
1 parent 83e6333 commit 442d4d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion hamilflow/models/sir.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ def __call__(self, t: TypeTime) -> pd.DataFrame:
infected = self.initial_condition.infected_0
recovered = self.initial_condition.recovered_0

results = []
results = [
{
"t": 0,
"S": susceptible,
"I": infected,
"R": recovered,
},
]

for t_i in np.array(t):
results.append(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_models/test_sir.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def test_sir_step(sir_model: SIR) -> None:
delta_s, delta_i, delta_r = sir_model._step(999, 1)
assert delta_s < 0
assert delta_i > 0
assert delta_r > 0
assert delta_r == 0


def test_sir_call(sir_model: SIR) -> None:
"""Test the call function of the SIR model."""
t = np.arange(0, 10)
t = np.arange(1, 10)
result = sir_model(t)
assert isinstance(result, pd.DataFrame)
assert len(result) == len(t)
assert len(result) == len(t) + 1
assert all(col in result.columns for col in ["t", "S", "I", "R"])

0 comments on commit 442d4d9

Please sign in to comment.