fix(weather): wind_d returns None when no valid samples, not fabricated 0.0° #1700

Merged
lekss361 merged 1 commit from fix/weather-wind-d-allnone into main 2026-06-17 18:34:47 +00:00
Owner

Проблема

weather_cache.py: при всех winddirection_10m_dominant = null (или пустом списке) циркулярное среднее давало atan2(0,0)=0.0 → фабриковало реальный 0° (север) вместо None.

Решение

Фильтр None upfront (как для t_max/t_min/uv); dominant_direction_deg: float|None; циркулярное среднее только при непустом списке; deg и label = None при отсутствии валидных сэмплов. Mixed null+valid работал и раньше (None уже фильтровались в суммах) — не тронут.

Verify

ruff clean; pytest70 passed, 1 skipped (+4 кейса all-None).

## Проблема `weather_cache.py`: при всех `winddirection_10m_dominant = null` (или пустом списке) циркулярное среднее давало `atan2(0,0)=0.0` → фабриковало реальный **0° (север)** вместо None. ## Решение Фильтр None upfront (как для t_max/t_min/uv); `dominant_direction_deg: float|None`; циркулярное среднее только при непустом списке; deg и label = None при отсутствии валидных сэмплов. Mixed null+valid работал и раньше (None уже фильтровались в суммах) — не тронут. ## Verify `ruff` clean; `pytest` → **70 passed, 1 skipped** (+4 кейса all-None).
lekss361 added 1 commit 2026-06-17 18:28:26 +00:00
fix(weather): wind_d returns None when no valid samples, not fabricated 0.0° (#weather-cache)
Some checks failed
CI / changes (push) Has been cancelled
CI / backend-tests (push) Has been cancelled
CI / frontend-tests (push) Has been cancelled
CI / openapi-codegen-check (push) Has been cancelled
CI / backend-tests (pull_request) Has been cancelled
CI / frontend-tests (pull_request) Has been cancelled
CI / openapi-codegen-check (pull_request) Has been cancelled
CI / changes (pull_request) Has been cancelled
6cf65eb26b
When all winddirection_10m_dominant samples were None (or the key was
absent), atan2(0, 0) produced 0.0° (due north) as a fabricated value.
Root causes:
  1. [None, None, ...] is truthy → entered circular-mean branch, but
     filtered sums x=y=0 → atan2(0,0)=0 → 0.0°
  2. Empty list → else 0.0 branch → same fabrication

Fix: filter None from wind_d before aggregation (consistent with t_max /
t_min / uv). Only compute circular mean when at least one valid sample
exists; otherwise dominant_direction_deg and dominant_direction_label are
None. Adds TestWindDirectionAllNone covering all-None, missing key, valid
samples sanity, and mixed None+valid cases.
lekss361 merged commit 9e6b0b1786 into main 2026-06-17 18:34:47 +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#1700
No description provided.