fix(forecasting): count non-zero observations in normalize guard (#1638) #1683

Merged
lekss361 merged 1 commit from fix/normalize-zero-fill-guard-1638 into main 2026-06-17 17:55:13 +00:00
Owner

Проблема (#1638)

normalize.py _count_full_years пропускал только None, а fill_month_grid zero-fill'ит отсутствующие месяцы units=0 → 36-месячная серия из нулей давала n_full_years=3 и проходила guard _MIN_FULL_YEARS>=2 как «достаточно данных».

Решение

В _count_full_years добавлен skip float(v)==0.0 — zero-filled месяцы не считаются полным годом.

Verify

ruff clean; pytest1218 passed, 1 skipped (+4 теста: all-zero fails, partial fails, real passes, public API unchanged).

Closes #1638

## Проблема (#1638) `normalize.py` `_count_full_years` пропускал только `None`, а `fill_month_grid` zero-fill'ит отсутствующие месяцы `units=0` → 36-месячная серия из нулей давала `n_full_years=3` и проходила guard `_MIN_FULL_YEARS>=2` как «достаточно данных». ## Решение В `_count_full_years` добавлен skip `float(v)==0.0` — zero-filled месяцы не считаются полным годом. ## Verify `ruff` clean; `pytest` → **1218 passed, 1 skipped** (+4 теста: all-zero fails, partial fails, real passes, public API unchanged). Closes #1638
lekss361 added 1 commit 2026-06-17 17:45:38 +00:00
fix(forecasting): count non-zero observations in normalize guard, not zero-filled buckets (#1638)
Some checks failed
CI / changes (push) Successful in 8s
CI / changes (pull_request) Successful in 6s
CI / backend-tests (push) Has been skipped
CI / frontend-tests (push) Has been skipped
CI / openapi-codegen-check (push) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 1m59s
CI / backend-tests (pull_request) Failing after 8m52s
494155654e
_count_full_years treated units=0 as a valid observation, so a series
where fill_month_grid zero-filled every month still accumulated 3 full
years and passed the _MIN_FULL_YEARS guard.  Zero-filled months carry no
seasonal signal, so they must be skipped in the year counter — the same
way None values already were.

Fix: skip v==0 alongside v is None in _count_full_years.
Add four tests: zero-filled 36-month series → n_full_years=0/applied=False;
partial-coverage years (only 6 non-zero months/year) → not counted as full;
real non-zero series still passes guard; normalize_demand on zero-filled
SalesSeries returns series unchanged.
lekss361 merged commit a1adf2fd19 into main 2026-06-17 17:55:13 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1683
No description provided.