From 8f1c5af635ef19d347d9825e402c9efee244fd82 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 12:50:07 +0000 Subject: [PATCH 1/2] Initial plan From f9c64b90cd0fbc8e14050b5f9be8b72c71fcc4e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 12:56:07 +0000 Subject: [PATCH 2/2] Improve test suite: shapes, dtypes, consistency, and error paths Add 21 new tests to tests/test_e57.py: - Array shape assertions: (n, 3) for points/color, (n, 1) for intensity - Dtype assertions: float64 for points, float32 for color/intensity - Partial-attribute shape tests: empty arrays have (0, 3) and (0, 1) shapes - Consistency tests: row counts match for full and partial-attribute files - Color value range: all float values in [0.0, 1.0] - Spherical-to-Cartesian: output is finite and 3-column - raw_xml structure: valid XML with e57Root element - Modern pytest.raises error-path tests alongside existing ones - Named constants BUNNY_N_POINTS / PIPE_N_POINTS to replace magic numbers in new tests --- tests/test_e57.py | 165 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/tests/test_e57.py b/tests/test_e57.py index f5598de..bf6f813 100644 --- a/tests/test_e57.py +++ b/tests/test_e57.py @@ -2,6 +2,9 @@ import numpy as np import pytest +BUNNY_N_POINTS = 30_571 +PIPE_N_POINTS = 1_220 + def test_raw_xml(): raw_xml = e57.raw_xml(r"testdata/bunnyFloat.e57") @@ -150,3 +153,165 @@ def test_raw_xml_just_xml(): assert "Failed to read E57" in str(e) assert "Failed creating paged CRC reader" in str(e) assert raised + + +# --------------------------------------------------------------------------- +# Shape assertions +# --------------------------------------------------------------------------- + + +def test_read_points_shape(): + pointcloud = e57.read_points(r"testdata/bunnyFloat.e57") + assert pointcloud.points.shape == (BUNNY_N_POINTS, 3) + + +def test_read_spherical_shape(): + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert pointcloud.points.shape == (PIPE_N_POINTS, 3) + + +def test_read_color_shape(): + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert pointcloud.color.shape == (PIPE_N_POINTS, 3) + + +def test_read_intensity_shape(): + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert pointcloud.intensity.shape == (PIPE_N_POINTS, 1) + + +# --------------------------------------------------------------------------- +# Dtype assertions +# --------------------------------------------------------------------------- + + +def test_read_points_dtype(): + pointcloud = e57.read_points(r"testdata/bunnyFloat.e57") + assert pointcloud.points.dtype == np.float64 + + +def test_read_color_dtype(): + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert pointcloud.color.dtype == np.float32 + + +def test_read_intensity_dtype(): + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert pointcloud.intensity.dtype == np.float32 + + +# --------------------------------------------------------------------------- +# Partial-attribute shape tests (file has no color or intensity) +# --------------------------------------------------------------------------- + + +def test_no_color_shape(): + """When a file has no color data the returned array should be (0, 3).""" + pointcloud = e57.read_points(r"testdata/bunnyFloat.e57") + assert pointcloud.color.shape == (0, 3) + assert pointcloud.color.dtype == np.float32 + + +def test_no_intensity_shape(): + """When a file has no intensity data the returned array should be (0, 1).""" + pointcloud = e57.read_points(r"testdata/bunnyFloat.e57") + assert pointcloud.intensity.shape == (0, 1) + assert pointcloud.intensity.dtype == np.float32 + + +# --------------------------------------------------------------------------- +# Consistency between arrays +# --------------------------------------------------------------------------- + + +def test_points_color_intensity_row_consistency(): + """points, color, and intensity must share the same row count.""" + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + n = pointcloud.points.shape[0] + assert pointcloud.color.shape[0] == n + assert pointcloud.intensity.shape[0] == n + + +def test_partial_attribute_row_consistency(): + """When color/intensity are absent their row count should be 0, not equal to points.""" + pointcloud = e57.read_points(r"testdata/bunnyFloat.e57") + assert pointcloud.points.shape[0] > 0 + assert pointcloud.color.shape[0] == 0 + assert pointcloud.intensity.shape[0] == 0 + + +# --------------------------------------------------------------------------- +# Value-range checks +# --------------------------------------------------------------------------- + + +def test_color_values_normalized(): + """Float color values should lie in [0.0, 1.0].""" + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert np.all(pointcloud.color >= 0.0) + assert np.all(pointcloud.color <= 1.0) + + +# --------------------------------------------------------------------------- +# Spherical-to-Cartesian conversion +# --------------------------------------------------------------------------- + + +def test_spherical_conversion_finite(): + """Spherical data converted to Cartesian should contain only finite values.""" + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert np.all(np.isfinite(pointcloud.points)) + + +def test_spherical_conversion_three_columns(): + """Spherical data converted to Cartesian should produce an (n, 3) array.""" + pointcloud = e57.read_points(r"testdata/pipeSpherical.e57") + assert pointcloud.points.ndim == 2 + assert pointcloud.points.shape[1] == 3 + + +# --------------------------------------------------------------------------- +# raw_xml structure +# --------------------------------------------------------------------------- + + +def test_raw_xml_structure(): + """raw_xml should return a valid XML document containing the e57Root element.""" + xml = e57.raw_xml(r"testdata/bunnyFloat.e57") + assert xml.startswith("