Skip to content

Add a test of Counts sampling with obs=None where observations are dense and the delay PMF is of length > 1 #660

Description

@dylanhmorris

Not for this PR: a test of Counts sampling with obs=None where observations are dense and the delay PMF is of length > 1 would have revealed the issue with NaN padding and -1s. Should add.

Originally posted by @dylanhmorris in #644 (comment)

Activity

  1. cdc-mitzimorris commented on Apr 20, 2026

    @cdc-mitzimorris
    Collaborator

    Tests added to test/test_observation_counts.py exercise this scenario: obs=None, dense, delay PMF longer than 1:

    • TestCountsBasics.test_delay_convolution (line 42) — 2-element delay PMF, obs=None, asserts predicted[:1] is NaN (init period), predicted[1:] is non-NaN, and observed >= 0 everywhere (line 60). If the NaN init positions were
      leaking -1s or NaNs into the sampled observed, this assertion would fail.
    • TestCountsCornerCases.test_long_delay_distribution (line 232) — 10-element delay PMF (the long_delay_pmf fixture), obs=None, asserts both ~jnp.isnan(result.observed) and result.observed >= 0 (lines 244–245).

    Combined with the current sample() logic in pyrenew/observation/count_observations.py:375 — safe_predicted = jnp.where(isnan, 1.0, predicted_counts) fed to noise.sample, so NaN-predicted positions sample from Poisson(1.0 + ε)
    rather than propagating NaN or -1 — the NaN-padding/-1s issue is both fixed and guarded by tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions