geotiff: add attrs canonical-tier locking test (#1984)#2009
Merged
Conversation
PR 4 of 7 from the attrs-contract plan in #1984. Adds test_attrs_contract_canonical_1984.py: a single fixture that exercises every canonical attr (crs, crs_wkt, transform, nodata, raster_type, extra_tags, gdal_metadata, gdal_metadata_xml, x_resolution / y_resolution / resolution_unit, _xrspatial_geotiff_contract), round-trips it through to_geotiff -> open_geotiff, and asserts presence + value per key. Sibling locking tests already cover the other tiers: aliases (#2002), pass-through (#2004), and per-backend stamping of the contract version (#2003). The canonical assertion list is what #1985 (parity matrix) and #1986 (round-trip invariants) will import. No production-code changes.
Addresses self-review on PR #2009: * Add per-backend canonical-key presence parametrisation (eager-numpy, dask-numpy, gpu, dask-gpu). The 7-PR plan in #1984 called for "one fixture per backend" coverage; previously only the eager read path was exercised. * Comment ``_CANONICAL_KEYS`` to explain the deliberate omission of ``raster_type`` (the implicit 'area' default is encoded as absence, so the constant cannot express it; the two dedicated raster_type tests handle both branches). * Drop ``AREA_OR_POINT: 'Area'`` from the shared ``_GDAL_META`` fixture so the point-branch test does not inherit an inconsistent GDAL_METADATA entry. * Relax the crs_wkt substring check to a regex covering 'WGS 84', 'WGS_1984', and 'WGS-84' so the assertion survives PROJ-version variation across CI platforms. * Note in a comment that ``gdal_metadata['TIFFTAG_SOFTWARE']`` and the raw Software TIFF tag (305) in ``extra_tags`` are independent channels the writer does not synchronise.
3 tasks
brendancol
added a commit
that referenced
this pull request
May 18, 2026
… (#2010) The writer in xrspatial.geotiff._geotags.build_geo_tags never emits the vertical GeoKey block, so attrs['vertical_crs'], attrs['vertical_citation'] and attrs['vertical_units'] cannot round-trip. PR6 (#2009) locked this "dropped on round-trip" behaviour. PR7 deprecates the three read-side emissions with a DeprecationWarning for one release cycle before removal. The attrs still emit; only the warning is new.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Coverage
test_attrs_contract_canonical_1984.pybuilds one synthetic DataArray that sets every canonical attr, round-trips it throughto_geotiff->open_geotiff, and runs per-key assertions:crscrs_wkttransformnodataextra_tagsgdal_metadatagdal_metadata_xmlx_resolution/y_resolution/resolution_unit_xrspatial_geotiff_contractraster_type'point'round-trips; absence (= implicit'area') is preservedA separate
test_every_canonical_key_presentruns the same fixture and asserts the full canonical set is present, so a writer that drops one key surfaces as one missing key rather than as a cascade of equality failures.Why this shape
The 7-PR plan called for "a single fixture exercising every attr, with explicit assertions per tier." Per-key tests share one fixture so a single canonical-attr regression points at the right key in the failure message. Issues #1985 (parity matrix) and #1986 (round-trip invariants) will import this assertion list.
Test plan
pytest xrspatial/geotiff/tests/test_attrs_contract_canonical_1984.py-- 12 passedpytest xrspatial/geotiff/tests/test_attrs_contract_aliases_1984.py xrspatial/geotiff/tests/test_attrs_contract_passthrough_1984.py xrspatial/geotiff/tests/test_attrs_contract_version_1984.py-- 31 passed (sibling tests unaffected)