Skip to content

Keep non-uniform image coordinates in NPZ transfers and HDF5 files - #4

Merged
PierreRaybaut merged 1 commit into
mainfrom
fix/non-uniform-image-coords
Oct 25, 2026
Merged

PierreRaybaut merged 1 commit into
mainfrom
fix/non-uniform-image-coords

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Contributor

Closes #3

Summary

Non-uniform image coordinates were lost by DataLab-Kernel, both in NPZ transfers with DataLab and in HDF5 workspace files: images came back with the pixel indices as coordinates.

  • NPZ (serialization_npz.py): same contract as DataLab (DataLab-Platform/DataLab@34ad31c): is_uniform_coords in metadata.json and, for non-uniform images, xcoords.npy / ycoords.npy (pixel centers). Lengths are checked against the image shape; archives without the flag (earlier versions) are read with uniform coordinates. Module docstring (format) updated.
  • HDF5 (backends/standalone.py, backends/webapi.py): new shared backends/h5coords.py storing is_uniform_coords and the xcoords / ycoords datasets; files without the flag are read with uniform coordinates.
  • The NPZ serializer now accesses the attributes guaranteed by Sigima objects directly (no getattr fallbacks), and the existing round-trip tests cover compression, labels, units and metadata.

Tests

  • NPZ: non-uniform round trip (with/without compression), uniform image without coordinate arrays, legacy archive without flag, invalid archives (missing/mismatched coordinates).
  • HDF5: standalone save/load of uniform and non-uniform images, legacy file, invalid file; Web API backend group save/load.
  • Live: non-uniform round trip through DataLab, skipped with DataLab < 1.4.0 (the PR CI on main installs DataLab from PyPI). Run locally against DataLab develop: passed.
  • 9 of the new tests fail on main. The other failures of the standalone suite in my local environment (87, missing matplotlib/plotly) are identical on main.

Note (pre-existing, not changed here)

DataLab develop reads SIGIMAX_DO_NOT_QUIT instead of DATALAB_DO_NOT_QUIT: with DataLab ≥ 1.4.0, conftest.py --start-datalab sees DataLab exit immediately unless SIGIMAX_DO_NOT_QUIT=1 is also set.

Images with non-uniform coordinates lost them in DataLab-Kernel: the NPZ
serializer used by the Web API backend wrote and read only x0, y0, dx and
dy, and so did the HDF5 save/load of the standalone and Web API backends.
For such images Sigima keeps the default x0 = y0 = 0 and dx = dy = 1, so
they came back with the pixel indices as coordinates, silently.

NPZ archives now follow the format of DataLab (>= 1.4.0): the
is_uniform_coords flag and, for non-uniform images, the pixel center
coordinates in xcoords.npy and ycoords.npy, whose lengths are checked
against the image shape. HDF5 image groups store the same flag and the
xcoords/ycoords datasets (h5coords module shared by both backends).
Archives and files without the flag (earlier versions) are still read with
uniform coordinates.

The NPZ serializer also accesses the attributes guaranteed by Sigima
objects directly instead of through getattr fallbacks, and the round-trip
tests cover compression, labels, units and metadata.

The live round-trip test is skipped with DataLab < 1.4.0, which does not
transfer non-uniform coordinates.

Closes #3

Assisted-by: Claude Opus 5.5
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.

Non-uniform image coordinates are lost in NPZ transfers and HDF5 workspace files

1 participant