Skip to content

Strengthen test suite: shapes, dtypes, array consistency, and error paths#42

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/improve-test-suite
Draft

Strengthen test suite: shapes, dtypes, array consistency, and error paths#42
Copilot wants to merge 2 commits into
mainfrom
copilot/improve-test-suite

Conversation

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The existing tests only asserted len() on returned arrays and used verbose try/except error patterns, leaving dtype, shape, and cross-array consistency unverified.

Changes

Named constants

  • BUNNY_N_POINTS = 30_571, PIPE_N_POINTS = 1_220 — eliminate magic numbers in new shape tests

Shape assertions (new tests verify 2-D structure, not just row count)

  • points → (n, 3), color → (n, 3), intensity → (n, 1)
  • Absent attributes return (0, 3) / (0, 1) rather than a flat empty array

Dtype assertions

  • points is float64; color and intensity are float32

Cross-array consistency

  • Full-attribute file: points, color, intensity share the same row count
  • Partial-attribute file (bunnyFloat): absent arrays have 0 rows while points is non-empty

Value-range and transformation checks

  • Float color values are in [0.0, 1.0]
  • Spherical→Cartesian output is finite and always 3-column

raw_xml structure

  • Asserts valid XML declaration and presence of e57Root element

Modern error-path tests

  • pytest.raises equivalents for all existing try/except error tests; original tests retained
# Example of newly verified invariants
pc = e57.read_points("testdata/pipeSpherical.e57")
assert pc.points.shape  == (1_220, 3)   # was: len == 1_220
assert pc.points.dtype  == np.float64
assert pc.color.shape   == (1_220, 3)
assert pc.color.dtype   == np.float32
assert pc.intensity.shape == (1_220, 1)
assert np.all(pc.color >= 0.0) and np.all(pc.color <= 1.0)

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
Copilot AI changed the title [WIP] Improve automated test suite for Python API Strengthen test suite: shapes, dtypes, array consistency, and error paths Jun 10, 2026
Copilot AI requested a review from dancergraham June 10, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants