Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/fix PeriodicBroadcaster #347

Closed
damonbayer opened this issue Jul 30, 2024 · 3 comments · Fixed by #349
Closed

Test/fix PeriodicBroadcaster #347

damonbayer opened this issue Jul 30, 2024 · 3 comments · Fixed by #349
Assignees
Labels
bug Something isn't working testing

Comments

@damonbayer
Copy link
Collaborator

damonbayer commented Jul 30, 2024

We do not currently have any tests for PeriodicBroadcaster, and I don't think it works how we want it to.

It seems like there is one too many inputs into these functions, leading to strange behavior. I think everything could be done without a period_size argument.

from pyrenew.arrayutils import PeriodicBroadcaster
import jax.numpy as jnp


base_array = jnp.array([1, 2, 3])

tile_broadcaster = PeriodicBroadcaster(
    offset=0, period_size=7, broadcast_type="tile"
)

tile_broadcaster(base_array, 10)
# Array([1, 2, 3, 1, 2, 3], dtype=int32)

repeat_broadcaster = PeriodicBroadcaster(
    offset=0, period_size=7, broadcast_type="repeat"
)

repeat_broadcaster(base_array, 10)
# Array([1, 1, 1, 1, 1, 1, 1, 2, 2, 2], dtype=int32)
@damonbayer damonbayer added bug Something isn't working testing labels Jul 30, 2024
@gvegayon
Copy link
Member

There's one test using the PeriodicBroadcaster implicitly: https://github.com/CDCgov/multisignal-epi-inference/blob/64e0ed832166d6c5ec2d0ca817c3cfdd1eeb0e0d/model/src/test/test_periodiceffect.py. I'll take a look at it.

@damonbayer damonbayer changed the title Test PeriodicBroadcaster Test/fix PeriodicBroadcaster Jul 31, 2024
@gvegayon
Copy link
Member

See if this works better:

dow_effects[pred_hosp_day_index] pred_hosp_day_index is an array of the same length as pred_hosp that indexes the days of the week (entries are 0,...6)

@damonbayer
Copy link
Collaborator Author

After discussing in standup, the plan is to

  • Use indexing instead of creating new arrays
  • Probably not have a common interface for the "tile" and "repeat" operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants