Skip to content

Add integer-value and population-conservation test for multinomial mode across all test frameworks #560

Open

Description

@RomeshA

Found in review of #539.

Problem

The only test of multinomial mode across frameworks is test_functional_all_framework_databook, which checks that the demos run. It does not check that compartment values stay integer or that people are conserved, and it only covers demo_projects, which contain no residual junctions and no duration groups. Both residual-junction bugs found in review would have been caught by an integer and conservation check on the existing tests/*.xlsx frameworks.

Implementation plan

  1. Add a parametrised test over every framework/databook pair in tests/ plus the library frameworks (including sir_vaccine) that runs in multinomial mode with a fixed seed and asserts:
    • every non-source compartment value is integer-valued (np.allclose(v, np.round(v)));
    • every compartment value is non-negative;
    • the total number of people across non-source compartments equals the initial total plus cumulative source inflow minus cumulative sink inflow at every timestep.
  2. Mark frameworks with duration groups as expected failures until the timed-compartment issue is resolved.
  3. Add a cheap guard in Compartment.resolve_outflows() under multinomial mode that raises ModelError if self[ti] is not integer-valued, so a future regression surfaces at the point of failure rather than as a silent truncation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions