fix(m02-df): 표 범위 칸에 숫자 하나(아래 = 위)면 「같음」 — 브레인 정함

- 아래 ≠ 위는 지금대로(아래 < 값 ≤ 위 · 빈 끝 열림) · 견치돌 「높이 4」 같은 줄이 맞음
- 시험 — 저장 다시 셈 4 → 0.7 줄 · apply_rule 4 / 3.5 / 3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KmELpdXFDRZHhfbGuRhSmL
This commit is contained in:
2026-10-01 20:01:27 +09:00
co-authored by Claude Opus 5.5
parent 868dc8e37f
commit 39c0d163ff
2 changed files with 21 additions and 1 deletions
@@ -314,7 +314,7 @@ def _rounded(value: Any, r: dict) -> Any:
def _lookup(rule: dict, block: Any, conds: dict) -> tuple[Any, str | None]:
"""표에서 찾기 — 같음 · 범위(「이름·아래」 < 값 ≤ 「이름·위」 · 빈 끝 열림) · 맞은 줄 하나만."""
"""표에서 찾기 — 같음 · 범위(아래 < 값 ≤ 위 · 빈 끝 열림 · 아래 = 위면 같음) · 맞은 줄 하나."""
if not isinstance(block, list) or len(block) < 2:
return None, "오류"
head = [str(h if h is not None else "") for h in block[0]]
@@ -336,6 +336,8 @@ def _lookup(rule: dict, block: Any, conds: dict) -> tuple[Any, str | None]:
def fits(row, lo=lo, hi=hi, x=x) -> bool:
low, high = _num_of(row[lo]), _num_of(row[hi])
if low is not None and low == high: # 숫자 하나(아래 = 위) = 같음(브레인 정함)
return x is not None and x == low
return (
x is not None
and (row[lo] is None or (low is not None and low < x))
+18
View File
@@ -547,6 +547,24 @@ def test_선_규칙_끝수_재료_조건_설계_때_정할_것(client: TestClien
assert _d(
_post(client, "/api/m02/df/save", {"logic": lg})["values"]["ports"]["f"]["합"]
) == int(Decimal("0.5") + 33000 + 3)
lg["boxes"][0]["input"]["variables"][0]["example"] = (
"견치돌" # 「높이 4」 줄 = 아래 = 위 → 같음(정함)
)
lg["boxes"][0]["input"]["variables"][1]["example"] = 4
assert _d(
_post(client, "/api/m02/df/save", {"logic": lg})["values"]["ports"]["f"]["합"]
) == int(Decimal("0.7") + 33000 + 4)
lookup = {
"kind": "lookup",
"col": "석공",
"conds": [{"col": "높이", "from": {"box": "v", "name": "높이"}}],
}
block = [["높이·아래", "높이·위", "석공"], [4, 4, 0.7], [None, 3, 0.5]]
assert [cf.dc.apply_rule(lookup, block, {"높이": h})[0] for h in (4, 3.5, 3)] == [
0.7,
None,
0.5,
]
lg["boxes"][0]["input"]["variables"][2]["example"] = "D999" # 맞는 재료 없음
lg["boxes"][0]["input"]["variables"][0]["example"] = "없는돌" # 표에 없는 조건 → 함수 멈춤
bad = _post(client, "/api/m02/df/save", {"logic": lg})["values"]