Merge remote-tracking branch 'origin/sub_laptop_3' into main_laptop_1

This commit is contained in:
2026-10-27 20:24:02 +09:00
9 changed files with 103 additions and 12 deletions
+5 -3
View File
@@ -240,7 +240,9 @@ def test_처음_만듦_측점수_NG_그림(project):
s10 = by["부록_절편"]["칸"]
block = 3 + SLICES + 1
assert by["부록_절편"]["인쇄"]["쪽나눔"] == [block * (i + 1) for i in range(len(REPS))]
assert "건기" in s10["A1"]["값"] and s10["A1"]["값"].startswith("부록 ① 절편 계산표 — No.3")
assert "건기" in s10["A1"]["값"] and s10["A1"]["값"].startswith(
"부록 ① 절편 계산표 — 3+0"
) # 566-1 누가 → No.+거리
assert s10["A4"]["값"] == 1 and s10["M4"]["값"] == pytest.approx(6.0 * 1.31)
assert s10[f"A{block}"]["값"] == "합계"
assert s10[f"E{block}"]["값"] == pytest.approx(sum(9.0 + i for i in range(SLICES)))
@@ -346,7 +348,7 @@ def test_광역요약_E07_저장본(project):
book, _ = store.load(project)
s7 = _sheets(book)["광역요약"]["칸"]
assert [s7[f"C{r}"]["값"] for r in range(12, 18)] == [100.0, 20.0, 12.0, 8.0, 0.0, 36.0]
assert [s7[f"A{r}"]["값"] for r in (22, 23)] == ["No.1", "No.2"] and "A24" not in s7
assert [s7[f"A{r}"]["값"] for r in (22, 23)] == ["1+0", "2+0"] and "A24" not in s7
assert (
s7["E22"]["값"] == "높음 (100.0 %)"
and s7["E23"]["값"] == "보통 (5.6 %)"
@@ -387,7 +389,7 @@ def test_갱신_사용자몫_불변_덮임(project):
assert (
by["표지"]["칸"]["C10"]["값"] == "산림청" and by["개요"]["칸"]["A22"]["값"] == "사용자 의견"
)
assert by["측점표"]["칸"]["A6"]["값"] == "No.0" # 프로그램 몫은 다시 씀
assert by["측점표"]["칸"]["A6"]["값"] == "0+0" # 프로그램 몫은 다시 씀
assert book["계산값"]["s2"]["B15"] == {"수": str(len(NG_AT) - 1)} # 수식이 새 값을 따라감
assert meta["fingerprint"] == build.analysis_fingerprint(project)
assert store.reset(project)
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
"""545-1 측점 표기 거울 — D04 `station_label`(py) ↔ `common_util_station.ts` `stationLabel(…, 1)`."""
"""545-1 측점 표기 거울 — D04 `station_label` · `common_util_station.py`(py) ↔ `common_util_station.ts`.
566-1 넓힘: 공용 파이썬 짝 `station_label(…, decimals 0 · 1)` · `infer_station_interval` 도 TS 와 같음."""
import json
import subprocess
@@ -10,6 +12,8 @@ PROJECT_ROOT = Path(__file__).resolve().parents[2]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from common_util.common_util_station import infer_station_interval # noqa: E402
from common_util.common_util_station import station_label as common_label # noqa: E402
from D04_PlanConfirm.D04_PlanConfirm_Export import station_label # noqa: E402
TS = PROJECT_ROOT / "common_util" / "common_util_station.ts"
@@ -38,17 +42,56 @@ new Function("exports", "module", js)(box.exports, box);
process.stdout.write(JSON.stringify(JSON.parse(process.argv[3]).map((v) => box.exports.stationLabel(v, 20, 1))));
"""
COMMON = r"""
const ts = require(process.argv[1]);
const src = require("fs").readFileSync(process.argv[2], "utf8");
const js = ts.transpileModule(src, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText;
const box = { exports: {} };
new Function("exports", "module", js)(box.exports, box);
const m = box.exports;
const { values, intervals, lists } = JSON.parse(process.argv[3]);
process.stdout.write(JSON.stringify({
labels: intervals.flatMap((i) => values.flatMap((v) => [m.stationLabel(v, i, 0), m.stationLabel(v, i, 1)])),
inferred: lists.map((l) => m.inferStationInterval(l.map((c) => ({ chainage_m: c })))),
}));
"""
INTERVALS = [20, 10, 25.5, 0]
LISTS = [
[],
[0],
[0, 20, 40, 47.3, 60, 80],
[0, 10, 20, 30, 50, 70],
[0, 5, 5, 3, 13],
[0, 19.96, 40],
]
def test_파이썬과_TS_측점_표기_같음():
def _node(script: str, payload) -> str:
proc = subprocess.run(
["node", "-e", SCRIPT, str(TYPESCRIPT), str(TS), json.dumps(VALUES)],
["node", "-e", script, str(TYPESCRIPT), str(TS), json.dumps(payload)],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
assert json.loads(proc.stdout) == [station_label(v) for v in VALUES]
return proc.stdout
def test_파이썬과_TS_측점_표기_같음():
assert json.loads(_node(SCRIPT, VALUES)) == [station_label(v) for v in VALUES]
def test_공용_파이썬_짝_TS_와_같음():
got = json.loads(_node(COMMON, {"values": VALUES, "intervals": INTERVALS, "lists": LISTS}))
assert got["labels"] == [
common_label(v, i, d) for i in INTERVALS for v in VALUES for d in (0, 1)
]
assert got["inferred"] == [
infer_station_interval([{"chainage_m": c} for c in lst]) for lst in LISTS
]
assert common_label(1234.5, 20) == "61+14.5" and common_label(1234.5, 20, 0) == "61+15"
assert got["inferred"][2:4] == [20, 10] # 최빈 · 10 m 셋 > 20 m 둘
def test_표기_꼴():