Skip to content

0.4: read onto a grid, source_translation, adopt checks attrs, pickling, scalar writes - #8

Merged
davidackerman merged 4 commits into
mainfrom
read-onto-0.4
Oct 23, 2026
Merged

davidackerman merged 4 commits into
mainfrom
read-onto-0.4

Conversation

@davidackerman

@davidackerman davidackerman commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

cellmap-analyze's three asks, so its ImageDataInterface wrapper can be deleted and every module can call worldarray directly (its draft PR #96 works in the voxel indices of one Grid per operation), and two of cellmap-flow's. Each one adds API, so this is 0.4.0. It has no placement change and no unit-table change.

  • vol.read_onto(grid, begin=None, end=None, ...) (new Behaviour 20) reads voxels [begin, end) of a Grid's spatial axes from the array, exactly that shape. It is defined as the read of the grid's index box at the grid's voxel size, anchored at the grid's corner, which is the composition cellmap-analyze writes by hand today.
    • At the array's own voxel size nothing is resampled, whatever the sub-voxel offset. Each grid voxel takes the stored voxel whose centre lies in it, even with method="linear", so cellmap-analyze's outputs don't change.
    • At any other voxel size the array is resampled onto the grid.
    • The grid's units are converted, and other axis names are refused.
  • Pickling by resolved path (Behaviour 11). A handle pickles, and reopens, with the path resolved against the working directory at open. wa.open("b.zarr/seg/s0") unpickled after an os.chdir used to raise FileNotFoundError; cellmap-analyze's dask workers change directory before they unpickle. vol.path still shows what the caller passed, and a reopened or unpickled handle shows the resolved path.
  • Scalar writes (Behaviour 13). write_index, write and write_chunk take a scalar, which fills the box.
    • The scalar is converted to the dtype only when its value survives: 0 into uint8 is written, while 300, -1, 0.5 and NaN raise. A float array takes any value it doesn't overflow, rounded to its precision.
    • The fill value over whole units leaves them absent, as an all-fill array already does.
  • vol.source_translation: the stored level's translation in units, beside source_voxel_size, under resample and relabel too. With it, cellmap-flow can drop its stored_placement helper.
  • Adopt compares attrs (Behaviour 11). create(exists="adopt") now checks every key given in attrs against the existing array's attributes, and names each one that differs or is missing; keys not given are not compared. An adopt given different attrs used to keep the old ones without saying so, the same way funlib's prepare_ds once kept an old offset. This is a behaviour change for callers that adopt with different attrs.

Spec section 2 has a new 0.4 block. Behaviours 11 and 13 are amended, Behaviour 20 is new, and the Tests section is updated. The README API brief and the changelog are updated, and the version is bumped in pyproject, __init__ and uv.lock. The suite has 179 tests.

https://claude.ai/code/session_0141wgF8mkGbjGfBFKfKhp64

cellmap-analyze's three asks so its ImageDataInterface wrapper can go. read_onto(grid,
begin, end) reads a Grid's voxels from an array, exactly that shape: the read of the
grid's index box at its voxel size anchored at its corner, so at the array's own voxel
size nothing is resampled (Behaviour 20). A handle pickles and reopens by the path
resolved at open, so a worker that changes directory finds the store. write_index, write
and write_chunk take a scalar, converted only when its value survives (Behaviour 13).

Claude-Session: https://claude.ai/code/session_0141wgF8mkGbjGfBFKfKhp64
Two of cellmap-flow's asks for 0.4. source_translation is the stored level's translation
in the requested units beside source_voxel_size, under resample and relabel, so its
stored_placement can go. create(exists="adopt") compares every key of attrs with the
existing array's attributes and names each that differs or is missing; it used to keep the
old ones silently.

Claude-Session: https://claude.ai/code/session_0141wgF8mkGbjGfBFKfKhp64
@davidackerman davidackerman changed the title 0.4: read onto a grid, pickle by resolved path, scalar writes 0.4: read onto a grid, source_translation, adopt checks attrs, pickling, scalar writes Oct 23, 2026
@davidackerman
davidackerman marked this pull request as ready for review October 23, 2026 02:00
@davidackerman
davidackerman merged commit cb8f774 into main Oct 23, 2026
4 checks passed
@davidackerman
davidackerman deleted the read-onto-0.4 branch October 23, 2026 02:01
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.

1 participant