Skip to content

Commit 86d329c

Browse files
committed
geotiff: assert spec.dtype in parity matrix harness (#1985)
Second review-pr pass on PR #2005 caught that ``_FixtureSpec.dtype`` was declared and documented but never read by ``assert_parity``. The only dtype check was reference-vs-actual inside ``_assert_pixels_equal``, which means a backend bug that uniformly upcasts in both the reference read and the backend read would not be caught. Assert ``actual.dtype == spec.dtype`` against the spec so a silent upcast that the reference also exhibits still fails the cell. Update the ``assert_parity`` docstring to match what the function actually does (dims/coords/transform vs reference; dtype, crs, nodata vs spec).
1 parent 3b68670 commit 86d329c

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

xrspatial/geotiff/tests/test_backend_parity_matrix.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,23 @@ def assert_parity(
256256
on-disk fixture, used to build the eager-numpy reference.
257257
258258
The eager-numpy read of the same file is the reference for the pixel
259-
array, coord values, dtype, dims, and transform tuple. Attrs are
260-
asserted against the spec rather than against the reference, so a
261-
bug that drops an attr in *every* backend still fails this cell.
259+
array, coord values, dims, and transform tuple. ``spec.dtype`` and
260+
``spec.expected_crs_epsg`` / ``spec.expected_nodata`` are asserted
261+
against the actual independently of the reference, so a bug that
262+
silently changes them in *every* backend still fails this cell.
262263
"""
263264
ref = open_geotiff(str(path))
264265

265266
# Pixel array, dtype, shape.
267+
actual_arr = _materialise(da)
266268
_assert_pixels_equal(
267-
_materialise(ref), _materialise(da), label=label,
269+
_materialise(ref), actual_arr, label=label,
270+
)
271+
272+
# Dtype against the spec, not just against the reference. Catches a
273+
# silent upcast that the reference would also exhibit.
274+
assert actual_arr.dtype == spec.dtype, (
275+
f"{label}: dtype {actual_arr.dtype} != spec dtype {spec.dtype}"
268276
)
269277

270278
# Dims + order.

0 commit comments

Comments
 (0)