시험을 `resources/tester` 로 옮긴 뒤 **한 건이 실패**하고 있었음 — `test_preview_cost` 가 짝 파일을 `tmp.tests.…` 로 불러 못 찾았음(옮긴 폴더에 없음). - `from resources.tester.test_preview_assets import …` 로 고침 - 실행 안내 문구 셋도 새 경로로(`diag_structures` · `helper_b06_fill_slope_length` · `test_common_util_crs`) - 정책 시험 설명은 **사실이 바뀌었으므로** 고쳐 적음 — 「git 밖이라」가 아니라 「옮겨서 함께 건너가되, 까닭은 여전히 값 옆(정본)에 두는 것이 옳다」 `resources/tester/` 1183 통과 / 22 건너뜀 / **실패 0**. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""미리보기 점 수집이 업로드 분석 시간을 늘리지 않는지 (2026-09-04 사용자 제약)."""
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.append(str(ROOT))
|
|
|
|
|
|
def _las_file() -> Path:
|
|
# ⚠ 시험이 `tmp/tests` → `resources/tester` 로 옮겨졌다(2026-09-09). 옛 경로로 부르면
|
|
# 옮긴 폴더에서 못 찾는다 — 같은 폴더의 짝을 새 경로로 부른다.
|
|
from resources.tester.test_preview_assets import _project_root # noqa: PLC0415
|
|
|
|
root = _project_root()
|
|
files = sorted((root / "B03_FileInput" / "input" / "las").glob("*.la*"))
|
|
if not files:
|
|
pytest.skip("LAS 파일이 없습니다.")
|
|
return files[0]
|
|
|
|
|
|
def test_collect_cost_is_small():
|
|
import laspy
|
|
import numpy as np
|
|
|
|
path = _las_file()
|
|
# ① 분류 통계만 (종전 동작)
|
|
started = time.perf_counter()
|
|
with laspy.open(path) as las_file:
|
|
counts: dict[int, int] = {}
|
|
for chunk in las_file.chunk_iterator(500_000):
|
|
values, chunk_counts = np.unique(
|
|
np.asarray(chunk.classification, dtype=np.uint8), return_counts=True
|
|
)
|
|
for value, count in zip(values.tolist(), chunk_counts.tolist(), strict=True):
|
|
counts[value] = counts.get(value, 0) + count
|
|
baseline = time.perf_counter() - started
|
|
|
|
# ② 지금 동작 (같은 길에 XY 를 성기게 주움)
|
|
from B03_FileInput.B03_FileInput_Engine_Analyze import analyze_las_metadata
|
|
|
|
started = time.perf_counter()
|
|
meta = analyze_las_metadata(path)
|
|
current = time.perf_counter() - started
|
|
|
|
print(f"\n분류 통계만 {baseline:.2f}s / 점 수집 포함 {current:.2f}s "
|
|
f"(차이 {current - baseline:+.2f}s, 점 {len(meta['preview_points'])}개)")
|
|
# 파일을 다시 읽지 않으므로 한 번 훑는 시간과 크게 다르지 않아야 한다.
|
|
assert current <= baseline * 1.5 + 1.0
|