Skip to content

Official Codebase of 3DCodeVerse

Python

cleanup: A4 — Delete five dead/test-only spatial defs and their tests

gaoypeng0e5c1f2fc977
diff --git a/harness/codeverse/spatial/frame_stats.py b/harness/codeverse/spatial/frame_stats.py
index e6a744a2..df04aade 100644
--- a/harness/codeverse/spatial/frame_stats.py
+++ b/harness/codeverse/spatial/frame_stats.py
@@ -176,7 +176,3 @@ def frame_gate(seq: SequenceStats, *, motion_expected: bool = True, gate: str =
"add structure: fbm layers, shapes (sdf), stars/particles, lines — the rubric rewards visual richness")
passed = not any(x.severity == Severity.ERROR for x in f)
return GateReport(gate=gate, passed=passed, findings=f)
-
-
-def stats_table(seq: SequenceStats) -> str:
- return "\n".join(seq.summary_lines())
diff --git a/harness/codeverse/spatial/render_scene.py b/harness/codeverse/spatial/render_scene.py
index 1f348172..9624feae 100644
--- a/harness/codeverse/spatial/render_scene.py
+++ b/harness/codeverse/spatial/render_scene.py
@@ -296,44 +296,6 @@ def read_metrics(out_dir: Path) -> dict[str, Any]:
return _read_json(Path(out_dir) / "metrics.json")
-def frame_table(source: RenderSet | dict[str, Any] | Path | str) -> str:
- """Compact per-view frame table for tools / judge context, one line per camera:
-
- view mean_lum dark% blown% content% cam_in_geom
- overview [authored] 0.34 5% 0% 48% no
-
- ``source`` may be a scene RenderSet (its metrics.json is located), a
- metrics payload dict, a render directory or a metrics.json path. Views
- without ``camera_checks`` yield an explanatory one-liner instead.
- """
- if isinstance(source, RenderSet):
- p = metrics_path_for(source)
- metrics = _read_json(p) if p else {}
- elif isinstance(source, dict):
- metrics = source
- else:
- p = Path(source)
- metrics = _read_json(p if p.suffix == ".json" else p / "metrics.json")
- checks = [c for c in metrics.get("camera_checks") or [] if isinstance(c, dict)]
- if not checks:
- return "frame table: no camera_checks available (scene not rendered or metrics.json missing)"
-
- def pct(v: Any) -> str:
- return f"{float(v):.0%}" if isinstance(v, (int, float)) else "-"
-
- def num(v: Any) -> str:
- return f"{float(v):.2f}" if isinstance(v, (int, float)) else "-"
-
- rows = [("view", "mean_lum", "dark%", "blown%", "content%", "cam_in_geom")]
- for c in checks:
- name = f"{c.get('name', '?')} [{c.get('kind', 'authored')}]"
- in_geom = c.get("camera_in_geometry")
- rows.append((name[:40], num(c.get("mean_lum")), pct(c.get("dark_frac")), pct(c.get("blown_frac")),
- pct(c.get("content_frac")), "-" if in_geom is None else ("YES" if in_geom else "no")))
- widths = [max(len(r[i]) for r in rows) for i in range(len(rows[0]))]
- return "\n".join(r[0].ljust(widths[0]) + " " + " ".join(r[i].rjust(widths[i]) for i in range(1, len(r))) for r in rows)
-
-
def metrics_path_for(rs: RenderSet) -> Path | None:
"""``metrics.json`` of a RenderSet: the stamped ``out_dir`` when present, else
guessed as a sibling of the sheet / views (rounds recorded before stamping)."""
diff --git a/harness/codeverse/spatial/silhouette.py b/harness/codeverse/spatial/silhouette.py
index 7793234c..5401c979 100644
--- a/harness/codeverse/spatial/silhouette.py
+++ b/harness/codeverse/spatial/silhouette.py
@@ -252,36 +252,3 @@ def best_view_match(
out.update(compare_silhouette(view.path, reference, diff_png=diff_png))
out["view"] = name
return out
-
-
-def silhouette_series(
- renders: Sequence[RenderView],
- reference_imgs: Sequence[Path | str],
- *,
- diff_dir: Path | str | None = None,
-) -> list[dict[str, Any]]:
- """For each reference image pick the best-matching render view (by IoU).
-
- Returns one dict per reference: ``{reference, best_view, iou, aspect_ratio_err,
- all: {view: iou}}`` (+ ``diff_png_path`` when ``diff_dir`` is given).
- """
- out: list[dict[str, Any]] = []
- for i, ref in enumerate(reference_imgs):
- scores: dict[str, dict[str, Any]] = {}
- for rv in renders:
- try:
- scores[rv.name] = compare_silhouette(rv.path, ref)
- except Exception as e: # unreadable image → skip that view
- scores[rv.name] = {"iou": 0.0, "error": f"{type(e).__name__}: {e}"}
- if not scores:
- out.append({"reference": str(ref), "best_view": None, "iou": 0.0, "all": {}})
- continue
- best = max(scores, key=lambda k: scores[k].get("iou", 0.0))
- rec: dict[str, Any] = {"reference": str(ref), "best_view": best, "iou": scores[best].get("iou", 0.0),
- "aspect_ratio_err": scores[best].get("aspect_ratio_err"),
- "all": {k: v.get("iou", 0.0) for k, v in scores.items()}}
- if diff_dir is not None:
- rv = next(r for r in renders if r.name == best)
- rec.update(compare_silhouette(rv.path, ref, diff_png=Path(diff_dir) / f"silhouette_diff_ref{i}_{best}.png"))
- out.append(rec)
- return out
diff --git a/harness/codeverse/spatial/tool_common.py b/harness/codeverse/spatial/tool_common.py
index 762ed53f..3038a567 100644
--- a/harness/codeverse/spatial/tool_common.py
+++ b/harness/codeverse/spatial/tool_common.py
@@ -20,11 +20,11 @@ from pydantic import ValidationError
from codeverse.contracts.artifacts import RenderSet, Severity
from codeverse.contracts.plan import ArticulatedPlan, GraphicsPlan, Plan, ScenePlan, StaticPlan
from codeverse.conventions import OBJECT_VIEWS, ViewPreset
-from codeverse.spatial.registry import Observation, ToolContext, ToolUnavailable, ToolUsageError
+from codeverse.spatial.registry import ToolContext, ToolUnavailable, ToolUsageError
from codeverse.workspace import Workspace
__all__ = [
- "ToolUnavailable", "unavailable_obs", "lazy", "call_adaptive", "spec_dict", "language_of", "track_of",
+ "ToolUnavailable", "lazy", "call_adaptive", "spec_dict", "language_of", "track_of",
"glb_path", "load_plan", "resolve_views", "check_mode", "tool_out_dir", "render_cache_dir",
"cached_render_glb", "gl_metrics_summary", "VIEW_BY_NAME", "RENDER_MODES",
]
@@ -37,16 +37,6 @@ RENDER_MODES = ("shaded", "wire", "normals", "silhouette", "depth", "clay")
#: every tool); re-exported here because that is where tools import it from.
-def unavailable_obs(tool: str, e: BaseException) -> Observation:
- """The Observation ``ToolDef.call`` builds for a :class:`ToolUnavailable`.
-
- Tools no longer need it — raise/propagate ``ToolUnavailable`` instead; it
- stays for callers that catch the exception themselves (e.g. an optional
- reader whose absence must not fail the whole tool).
- """
- return Observation.error(f"tool {tool} unavailable: {type(e).__name__}: {e}")
-
-
def lazy(module: str, attr: str) -> Callable[..., Any]:
"""Import ``module.attr`` now; raise :class:`ToolUnavailable` with a clear reason."""
try:
diff --git a/harness/runtime_js/lib/census.mjs b/harness/runtime_js/lib/census.mjs
index c2756238..f13e7d6e 100644
--- a/harness/runtime_js/lib/census.mjs
+++ b/harness/runtime_js/lib/census.mjs
@@ -71,11 +71,6 @@ export function findNonFinitePositions(root) {
return visit(root, []);
}
-/** True when any position attribute contains a non-finite value. */
-export function hasNonFinitePositions(root) {
- return findNonFinitePositions(root) !== null;
-}
-
function materialSummary(m) {
const out = { name: m.name || '', type: m.type };
if (m.color && m.color.isColor) out.color = '#' + m.color.getHexString();
diff --git a/harness/tests/scene_runtime/test_render_scene.py b/harness/tests/scene_runtime/test_render_scene.py
index 433e8de0..d74fc61e 100644
--- a/harness/tests/scene_runtime/test_render_scene.py
+++ b/harness/tests/scene_runtime/test_render_scene.py
@@ -204,32 +204,3 @@ def test_request_failure_line_filters_phantom_aborts():
assert res["real"] == "request failed: /assets/a.glb (net::ERR_CONNECTION_REFUSED)"
assert res["offsite"] is None
assert res["cs_default"] == 20000 and res["cs_flag"] == 3000 and res["cs_small_budget"] == 6000
-
-
-def test_frame_table_from_metrics_dict():
- from codeverse.spatial.render_scene import frame_table
-
- metrics = {"camera_checks": [
- {"name": "overview", "kind": "authored", "mean_lum": 0.34, "dark_frac": 0.05, "blown_frac": 0.0,
- "content_frac": 0.48, "camera_in_geometry": False},
- {"name": "buried", "kind": "orbit", "mean_lum": 0.02, "dark_frac": 0.91, "blown_frac": 0.0,
- "content_frac": 0.01, "camera_in_geometry": True},
- ]}
- table = frame_table(metrics)
- lines = table.splitlines()
- assert lines[0].split() == ["view", "mean_lum", "dark%", "blown%", "content%", "cam_in_geom"]
- assert "overview [authored]" in lines[1] and "0.34" in lines[1] and "48%" in lines[1] and lines[1].endswith("no")
- assert "buried [orbit]" in lines[2] and "91%" in lines[2] and lines[2].endswith("YES")
- assert "no camera_checks" in frame_table({})
-
-
-@needs_browser
-def test_frame_table_from_renderset(starter_ws):
- from codeverse.spatial.render_scene import frame_table
-
- out = starter_ws.renders_dir(4)
- rs = render_scene(starter_ws, out, times=(0.0,), width=320, height=180, fps_seconds=0, orbit_views=SCENE_VIEWS[:1], sheet=False)
- table = frame_table(rs)
- assert "overview [authored]" in table and "mean_lum" in table
- assert table == frame_table(out)
diff --git a/harness/tests/spatial_tools/test_silhouette.py b/harness/tests/spatial_tools/test_silhouette.py
index 0c1f586e..6f7095e3 100644
--- a/harness/tests/spatial_tools/test_silhouette.py
+++ b/harness/tests/spatial_tools/test_silhouette.py
@@ -5,8 +5,7 @@ from pathlib import Path
import pytest
from PIL import Image, ImageDraw
-from codeverse.contracts.artifacts import RenderView
-from codeverse.spatial.silhouette import compare_silhouette, foreground_mask, silhouette_series
+from codeverse.spatial.silhouette import compare_silhouette, foreground_mask
def _disc(path: Path, size: tuple[int, int], box: tuple[int, int, int, int], bg=(240, 240, 240), fg=(30, 30, 30)) -> Path:
@@ -58,16 +57,6 @@ def test_unreliable_when_empty(tmp_path: Path) -> None:
assert r["iou"] == 0.0 and not r["reliable"]
-def test_series_picks_best_view(tmp_path: Path) -> None:
- ref = _disc(tmp_path / "ref.png", (300, 300), (50, 50, 250, 250))
- good = _disc(tmp_path / "good.png", (300, 300), (40, 40, 260, 260))
- bad = _disc(tmp_path / "bad.png", (300, 300), (20, 120, 280, 180))
- views = [RenderView(name="front", path=str(bad)), RenderView(name="top", path=str(good))]
- res = silhouette_series(views, [ref], diff_dir=tmp_path)
- assert res[0]["best_view"] == "top" and res[0]["iou"] > 0.9
- assert Path(res[0]["diff_png_path"]).is_file()
-
-
def test_a_photo_the_background_model_failed_on_is_unreliable(tmp_path: Path) -> None:
"""A busy photo floods to a corner-to-corner mask, and the AREA test does not see it.