added ruff for code review

This commit is contained in:
ykcheungab
2026-09-27 19:21:03 +08:00
parent f91ac9d3db
commit e7dfd4f90b
28 changed files with 434 additions and 69 deletions
+2 -2
View File
@@ -14,11 +14,11 @@ from orisys_sensor_design.deform import (
DEFAULT_PROBE,
DEFORM_JOB_FILENAME,
DEFORM_JOB_SCHEMA,
FRAMES_NPZ_FILENAME,
DEFORM_REPORT_FILENAME,
FRAMES_NPZ_FILENAME,
PatternInfo,
ProbeConfigError,
ProbeFrame,
PatternInfo,
build_deform_job,
deform_job_path,
frame_plan,
+2 -3
View File
@@ -9,12 +9,12 @@ import pytest
np = pytest.importorskip("numpy")
from orisys_sensor_design.manifest import RevisionPaths, repo_root
from orisys_sensor_design.optics import (
AIR_INDEX,
Interface,
OpticalStack,
OpticsConfigError,
OpticsLayer,
OpticalStack,
intersect_mesh,
load_optics_block,
quantify,
@@ -24,7 +24,6 @@ from orisys_sensor_design.optics import (
trace_ray,
validate_optics_block,
)
from orisys_sensor_design.manifest import RevisionPaths, repo_root
REPO = repo_root()
+2 -4
View File
@@ -2,7 +2,6 @@
from __future__ import annotations
import math
import sys
from pathlib import Path
@@ -11,14 +10,13 @@ import pytest
np = pytest.importorskip("numpy")
from orisys_sensor_design.optics import (
AIR_INDEX,
Interface,
OpticsLayer,
OpticalStack,
OpticsLayer,
camera_rays,
quantify,
sample_stack,
summarize,
quantify,
)
from orisys_sensor_design.optics_plot import (
DEFAULT_SANITY_MM,
+1 -1
View File
@@ -341,7 +341,7 @@ def test_reference_cross_printable_flag(tmp_path: Path) -> None:
_polygon("patch-1", "0,0 50,0 50,50 0,50")
+ "\n"
+ ' <g id="reference-cross">\n'
+ f' <rect id="cross-arm-0" x="0" y="0" width="20" '
+ ' <rect id="cross-arm-0" x="0" y="0" width="20" '
+ f'height="{height_px}" fill="#ff0000"/>\n'
+ " </g>"
)
+4 -1
View File
@@ -76,11 +76,14 @@ requires_blender = pytest.mark.skipif(
def _run_blender(script: Path, job: Path, timeout: int = 900) -> subprocess.CompletedProcess:
assert BLENDER is not None
# check=False is deliberate: several tests assert on non-zero Blender exit
# codes (2/3), so a non-zero status is data, not an error to raise on.
return subprocess.run(
[str(BLENDER), "-b", str(SOURCE_BLEND), "-P", str(script), "--", "--job", str(job)],
capture_output=True,
text=True,
timeout=timeout,
check=False,
)
@@ -248,7 +251,7 @@ def test_job_carries_the_hard_render_settings(paths, settings, tmp_path):
assert job["objects"] == {"mesh": "sensing_surface", "camera": "cam_sensor"}
assert job["null_frame"] == {"name": REFERENCE_NULL_NAME, "seed": 1}
assert job["artifacts"]["report"] == str(
(Path(tmp_path).resolve() / render.MANIFEST_FILENAME)
Path(tmp_path).resolve() / render.MANIFEST_FILENAME
)
assert job["artifacts"]["frames_npz"] == str(
deform.probe_artifact_paths(Path(tmp_path))["frames"]
-2
View File
@@ -195,7 +195,6 @@ def _stub_sdk(monkeypatch: pytest.MonkeyPatch, calls: dict, mask_mode: str = "va
arrays["valid_mask"] = np.ones((4, 4), bool)
arrays["world_xyz"] = np.zeros((4, 4, 3), np.float32)
np.savez(map_path, **arrays)
return None
monkeypatch.setattr(geometry, "scale_camera_geometry", fake_scale_camera_geometry)
monkeypatch.setattr(precompute, "build_or_load_domain", fake_build_or_load_domain)
@@ -306,7 +305,6 @@ def test_a_map_without_a_valid_mask_is_fatal(
calls["build_kwargs"] = kwargs
height, width = int(kwargs["out_height"]), int(kwargs["out_width"])
np.savez(map_path, map_x=np.zeros((height, width), np.float32))
return None
monkeypatch.setattr(precompute, "build_or_load_domain", build_without_mask)
with pytest.raises(uv.UvMapError, match="valid_mask"):