fix: 우산분실각이 비 오는 날 하루 종일 0점이던 것 — 지금과 앞으로만 보는 식으로

- 예전 식은 '그 구간에 비 소식이 있으면 0점, 앞서 내린 비가 없으면 0점'이라 구간마다 비 예보가 있는 날은 종일 0점이었고, 앞서 내린 비는 관측이 아니라 저장된 예보로 판단해 실제와 어긋났음
- 새 식: 우산을 챙겼을 정도(지금 비가 오면 100%, 아니면 지금부터 자정까지 가장 높은 비 확률) × 비가 안 오는 시간의 비율(100% − 남은 시각 비 확률 평균). 지난 시각은 보지 않고 0점 조건을 없앰. 내일·토·일 칸은 그날 9~22시로 같은 식
- 설명·요소 이름('우산 안 쓰는 시간')·점수 구간 문장을 새 뜻에 맞춤 (문구는 검토 전), 각 계산 기준 문서 다시 생성
This commit is contained in:
skkim committed 2026-11-23 16:50:22 +09:00
1 parent b0e6a01157
commit 62d79702ab
7 files changed
+111 -49

No files matched your search

+12
View File
@@ -164,6 +164,18 @@ def test_umbrella_raining_now_and_all_remaining_hours_rain_is_100():
assert parts["day"].score == 100
def test_umbrella_lost_current_slot_looks_at_now_and_later_only():
"""우산분실각은 지금과 앞으로만 본다. 11:30, 16~23시 비 예보(지금은 안 옴): 챙겼을 정도 100% × 안 쓰는 시간 5/13 → 38점.
아침에 비가 왔었는지(지난 시각)는 점수에 들어가지 않는다."""
defn = _defn([{"from": 9, "to": 22}])
defn.weight_temp, defn.weight_rain = 0, 100
defn.factor_rules = defn.factor_rules | {"rain": {"dir": "dry", "span": "rest_of_day", "kind": "unused"}}
now = datetime(2026, 10, 8, 11, 30, tzinfo=KST)
later = slot_results(defn, DAY, REGION, _rain_at(set(range(16, 24))), {}, CTX, SUNSET, now)["day"].score
with_morning_rain = slot_results(defn, DAY, REGION, _rain_at({6, 7, 8} | set(range(16, 24))), {}, CTX, SUNSET, now)["day"].score
assert later == with_morning_rain == 38
def test_umbrella_raining_now_needs_the_current_hours_own_forecast():
"""13시 예보 행이 없고 14시에만 비가 오면 '지금 비'가 아니다. 다음 시각의 비를 지금으로 읽으면 안 된다 → 남은 10시간 중 1시간, 10점."""
now = datetime(2026, 10, 8, 13, 30, tzinfo=KST)
+57 -1
View File
@@ -408,7 +408,10 @@ def test_gak_weights_after_removing_activity_hours(code, expected):
def test_umbrella_gak_use_the_rain_rules_the_owner_asked_for():
assert _SEED["umbrella"].factor_rules["rain"] == {"dir": "wet", "span": "rest_of_day", "now_base": 70}
assert _SEED["umbrella_lost"].factor_rules["rain"]["dir"] == "dry"
lost = _SEED["umbrella_lost"]
assert lost.factor_rules["rain"] == {"dir": "dry", "span": "rest_of_day", "kind": "unused", "label": "우산 안 쓰는 시간"}
# 지난 시각(앞서 내린 비)은 보지 않는다. 지금과 앞으로만으로 점수를 내므로 0점 조건이 없다
assert lost.zero_rules == [] and lost.windows == [{"from": 9, "to": 22}]
@pytest.mark.parametrize("code, calm, lively", [
@@ -507,6 +510,8 @@ def test_humidity_cap():
def test_axis_label_can_be_overridden():
assert axis_label("temp", {"temp": {"type": "higher", "label": "덜 추움"}}) == "덜 추움"
assert axis_label("rain", {"rain": {"dir": "dry", "label": "우산 안 쓰는 시간"}}) == "우산 안 쓰는 시간"
assert axis_label("rain", {"rain": {"dir": "dry"}}) == "비 안 옴"
def test_umbrella_lost_needs_rain_that_stopped():
@@ -569,6 +574,57 @@ def test_umbrella_estimate_averages_the_window_hours_of_the_mid_forecast():
assert r.score == 33
def _lost(probs, raining_now, at_now=True):
"""우산분실각 방식: 우산을 챙겼을 정도(지금 비가 오면 100%, 아니면 남은 시각 중 가장 높은 비 확률) × 비가 안 오는 시간의 비율."""
defn = _defn(
weight_temp=0, weight_rain=100, weight_wind=0, weight_humidity=0, weight_air=0, weight_time=0,
factor_rules=_defn().factor_rules | {"rain": {"dir": "dry", "span": "rest_of_day", "kind": "unused"}}, zero_rules=[],
)
hours = [_h(11 + i, prob=p, rain=RainType.RAIN if i == 0 and raining_now else RainType.NONE) for i, p in enumerate(probs)]
return evaluate(defn, [hours], replace(CTX, at_now=at_now))
@pytest.mark.parametrize("probs, raining_now, score", [
([100] + [0] * 12, True, 92), # 지금 비 오고 곧 그침: 들고 나온 우산을 12/13 시간 안 씀
([0] * 7 + [100] * 6, False, 54), # 지금은 안 오는데 저녁에 비: 챙긴 우산을 7/13 시간 들고만 다님
([0] * 7 + [80] * 6, False, 50), # 저녁 비 80%: 챙겼을 정도 80% × 안 쓰는 시간 63%
([60] * 13, True, 37), # 지금 비 오고 계속 60%
([30] * 13, False, 21), # 하루 종일 30%: 챙겼을 정도 30% × 안 쓰는 시간 70%
([100] * 13, True, 0), # 하루 종일 비: 계속 쓰니 두고 올 일이 없음
([0] * 13, False, 0), # 비 소식 없음: 들고 나온 우산이 없음
])
def test_umbrella_lost_is_how_much_a_carried_umbrella_goes_unused(probs, raining_now, score):
assert _lost(probs, raining_now).score == score
def test_umbrella_lost_counts_raining_now_only_when_the_evaluation_starts_now():
"""지금 비가 오면 우산은 확실히 들고 있다(100%). 다른 구간·내일 칸은 '지금'이 없어 예보 확률만큼만."""
assert _lost([40] + [0] * 12, raining_now=True).score == 92
assert _lost([40] + [0] * 12, raining_now=True, at_now=False).score == 39
def test_umbrella_lost_note_shows_both_parts():
note = _lost([0] * 7 + [80] * 6, raining_now=False).notes["rain"]
assert "80%" in note and "63%" in note and "지금 비" not in note
assert "지금 비" in _lost([100] + [0] * 12, raining_now=True).notes["rain"]
def test_umbrella_lost_estimate_uses_the_mid_forecast_hours():
"""중기예보 날 9~21시: 오전(9~11시) 비 100%, 오후 0% → 챙겼을 정도 100% × 안 쓰는 시간 10/13 → 77점."""
defn = _defn(
weight_temp=0, weight_rain=100, weight_wind=0, weight_humidity=0, weight_air=0, weight_time=0,
factor_rules=_defn().factor_rules | {"rain": {"dir": "dry", "span": "rest_of_day", "kind": "unused"}}, zero_rules=[],
)
assert estimate(defn, _fc(am=100, pm=0), [list(range(9, 22))], CTX).score == 77
def test_umbrella_lost_seed_no_longer_scores_zero_while_it_rains():
"""운영에서 본 문제: 비가 오는 날은 하루 종일 0점이었다. 지금 비가 오고 저녁에 그치면 점수가 난다."""
hours = [_h(h, prob=100 if h < 18 else 10, rain=RainType.RAIN if h < 18 else RainType.NONE) for h in range(16, 24)]
r = evaluate(_SEED["umbrella_lost"], [hours], replace(CTX, at_now=True))
assert r.score == 68 and r.zero_reason is None # 16·17시 비, 18~23시 10%: 100 − (100×2 + 10×6) ÷ 8
def test_single_factor_gak_is_not_pulled_down_by_its_own_weakest_factor():
"""요소가 하나면 '가장 낮은 요소로 깎기'를 하지 않는다. 안 그러면 72점이 67점이 된다."""
r = _umbrella([100] + [0] * 12, raining_now=True)