test: cover malformed Gaussian parameters
Browse files
tests/test_inspect_gaussian_ply.py
CHANGED
|
@@ -32,3 +32,32 @@ def test_gaussian_inspector_rejects_missing_evidence_field(tmp_path):
|
|
| 32 |
assert "missing fields" in str(exc)
|
| 33 |
else:
|
| 34 |
raise AssertionError("missing Gaussian evidence fields should fail")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
assert "missing fields" in str(exc)
|
| 33 |
else:
|
| 34 |
raise AssertionError("missing Gaussian evidence fields should fail")
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def test_gaussian_inspector_rejects_invalid_rotation_and_confidence(tmp_path):
|
| 38 |
+
path = tmp_path / "bad_gaussians.ply"
|
| 39 |
+
write_gaussian_ply(
|
| 40 |
+
path,
|
| 41 |
+
np.array([[0, 0, 1]], dtype=np.float32),
|
| 42 |
+
np.array([[255, 0, 0]], dtype=np.uint8),
|
| 43 |
+
np.array([1.5], dtype=np.float32),
|
| 44 |
+
np.array([0], dtype=np.int32),
|
| 45 |
+
np.array([1], dtype=np.int32),
|
| 46 |
+
rotations=np.array([[2, 0, 0, 0]], dtype=np.float32),
|
| 47 |
+
scales=np.ones((1, 3), dtype=np.float32),
|
| 48 |
+
opacities=np.array([0.5], dtype=np.float32),
|
| 49 |
+
)
|
| 50 |
+
lines = path.read_text(encoding="utf-8").splitlines()
|
| 51 |
+
end = lines.index("end_header")
|
| 52 |
+
properties = [line.split()[-1] for line in lines[:end] if line.startswith("property ")]
|
| 53 |
+
fields = lines[end + 1].split()
|
| 54 |
+
fields[properties.index("rot_0")] = "2"
|
| 55 |
+
fields[properties.index("confidence")] = "1.5"
|
| 56 |
+
lines[end + 1] = " ".join(fields)
|
| 57 |
+
path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
| 58 |
+
try:
|
| 59 |
+
inspect_gaussian_ply(path)
|
| 60 |
+
except ValueError as exc:
|
| 61 |
+
assert "normalized quaternions" in str(exc)
|
| 62 |
+
else:
|
| 63 |
+
raise AssertionError("invalid Gaussian quaternion should fail")
|