Skip to content

Commit

Permalink
code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidari committed Sep 16, 2024
1 parent 0f3e2fd commit 542ad84
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pyrenew/convolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _new_scanner(
* jnp.einsum("i...,i...->...", array_to_convolve, history_subset)
)
latest = jnp.concatenate(
[history_subset[1:], jnp.expand_dims(new_val, axis=0)], axis=0
[history_subset[1:], new_val[jnp.newaxis]], axis=0
)
return latest, new_val

Expand Down Expand Up @@ -166,7 +166,7 @@ def _new_scanner(
m2 * m_net1 * jnp.einsum("i...,i...->...", arr2, history_subset)
)
latest = jnp.concatenate(
[history_subset[1:], jnp.expand_dims(new_val, axis=0)], axis=0
[history_subset[1:], new_val[jnp.newaxis]], axis=0
)
return latest, (new_val, m_net1)

Expand Down
8 changes: 4 additions & 4 deletions pyrenew/latent/infections.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def sample(
f"generation interval length: {gen_int.size}."
)

if I0.ndim != Rt.ndim:
if I0.shape[1:] != Rt.shape[1:]:
raise ValueError(
"Initial infections and Rt must have the same dimensions. "
f"Got initial infections of shape {I0.shape} "
f"and Rt of shape {Rt.shape}."
"Initial infections and Rt must have the same batch shapes. "
f"Got initial infections of batch shape {I0.shape[1:]} "
f"and Rt of batch shape {Rt.shape[1:]}."
)

gen_int_rev = jnp.flip(gen_int)
Expand Down
8 changes: 4 additions & 4 deletions pyrenew/latent/infectionswithfeedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ def sample(
f"and generation interval length {gen_int.size}."
)

if I0.ndim != Rt.ndim:
if I0.shape[1:] != Rt.shape[1:]:
raise ValueError(
"Initial infections and Rt must have the same dimensions. "
f"Got initial infections of shape {I0.shape} "
f"and Rt of shape {Rt.shape}."
"Initial infections and Rt must have the same batch shapes. "
f"Got initial infections of batch shape {I0.shape[1:]} "
f"and Rt of batch shape {Rt.shape[1:]}."
)

gen_int_rev = jnp.flip(gen_int)
Expand Down
4 changes: 2 additions & 2 deletions test/test_infection_and_infectionwithfeedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_infections_with_feedback_invalid_inputs():

with pytest.raises(
ValueError,
match="Initial infections and Rt must have the same dimensions.",
match="Initial infections and Rt must have the same batch shapes.",
):
InfectionsWithFeedback(
gen_int=gen_int,
Expand All @@ -70,7 +70,7 @@ def test_infections_with_feedback_invalid_inputs():

with pytest.raises(
ValueError,
match="Initial infections and Rt must have the same dimensions.",
match="Initial infections and Rt must have the same batch shapes.",
):
infections(
gen_int=gen_int,
Expand Down

0 comments on commit 542ad84

Please sign in to comment.