Make infection feedback a constructor option of the latent classes; remove `infection_process`

クローズ
#902 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, backend

調査の方向性

Start with pyrenew/latent/base.py and the sample methods and constructors in population_infections.py and subpopulation_infections.py; compare their current renewal calls with InfectionsWithFeedback.sample in infection_process.py. Then update the exports and tests listed in the issue, including builder and integration coverage. Done means both latent classes support the paired feedback options and preserve the documented behavior, while the standalone infection classes still pass their tests.

索引モデルが issue の本文から書いたものです。

説明

model pyrenew

Remove the InfectionProcess protocol and the infection_process constructor argument added in #847. Infection feedback becomes two optional constructor arguments of PopulationInfections and SubpopulationInfections, and each latent class defines its own renewal step.

Motivation
  • Only two renewal steps exist, and one contains the other. Feedback with strength 0 gives exactly plain renewal. A pluggable protocol is more general than the code needs.
  • Feedback should be easy to find. It should be a documented option of the latent class, not a separate object users must know to build.
  • Coupled models can't use the protocol. MobilitySubpopulationInfections (#901) needs the population fractions in its renewal step, which the protocol does not pass. Without the protocol, every latent class defines its renewal step the same way.
What the user writes

Today:

builder.configure_latent(
    PopulationInfections,
    ...,
    infection_process=InfectionsWithFeedback(
        name="infections",
        infection_feedback_strength=strength_rv,
        infection_feedback_pmf=feedback_pmf_rv,
    ),
)

After this change:

builder.configure_latent(
    PopulationInfections,
    ...,
    infection_feedback_strength_rv=strength_rv,
    infection_feedback_pmf_rv=feedback_pmf_rv,
)

SubpopulationInfections takes the same two arguments. Without feedback, nothing changes.

Behavior
  • Given the same random variables and seed, results are identical to passing infection_process=InfectionsWithFeedback(...) today.
  • Feedback is off unless both arguments are given. One without the other raises ValueError.
  • A feedback PMF whose length differs from the generation interval, or a strength that does not broadcast to the shape of Rt, raises ValueError with both shapes. Today the PMF case is a shape error from jnp.einsum.
  • Passing infection_process raises TypeError.
  • The recorded Rt used by the renewal equation is renamed: rt_single_effective to rt_single_adjusted, and rt_subpop_effective to rt_subpop_adjusted. "Adjusted" matches compute_infections_from_rt_with_feedback (Rt_raw in, Rt_adjusted out) and avoids a second meaning of "effective reproduction number". rt_single and rt_subpop (raw Rt) are unchanged.
  • Infections and InfectionsWithFeedback are unchanged; pyrenew-multisignal uses InfectionsWithFeedback directly.
Breaking change

infection_process, InfectionProcess, and the _effective sites were added in #847 (2026-07-01) and are in no tagged release. One CDC-internal project passes infection_process to SubpopulationInfections; it moves the two arguments onto the latent class and reads the renamed sites. The release notes show the before and after code and the site renames.

Order

Land before #901, which builds on the renewal step and names from this change.

Out of scope
  • Changing the feedback model.
  • Turning feedback on by default.
主要言語
Python
スター
30
フォーク
11
平均マージ
6日 20時間
マージ済み PR(30日)
5

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CDCgov/PyRenew のほかの issue

CDCgov/PyRenew の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。