Files
dashboard-cpsp/scripts/weigh_sample_count.py
T
2026-08-26 13:46:05 +07:00

22 lines
653 B
Python

"""Generate chicken_weight.chicken_count as weigh-sample size (not leftover birds)."""
from __future__ import annotations
import random
# Deterministic: same cycle always gets the same sample sizes.
SAMPLE_RNG_SEED = 20260522
SAMPLE_MIN = 180
SAMPLE_MAX = 320
def weigh_sample_count(*, average_weight: float, rng: random.Random | None = None) -> int:
"""Birds used to compute that day's average_weight.
0 when there is no BW reading (age 38+ user decision).
"""
if average_weight is None or float(average_weight) <= 0:
return 0
rng = rng or random.Random(SAMPLE_RNG_SEED)
return rng.randint(SAMPLE_MIN, SAMPLE_MAX)