Small, low-priority bug found while adding zarr3 support (#140/#141).
Bug
read_tensorstore() squeezes singleton dims:
# src/microsim/cosem/_tstore.py
slices = tuple((slice(None) if s > 1 else 0) for s in data.shape)
data = data[slices]
then reverses axes based on grid_scale:
slices = tuple(slice(None, None, int(np.sign(scale))) for scale in img.grid_scale)
data = data[slices]
When the smallest pyramid level has an axis of size 1 (e.g. s11 of jrc_mus-skel-muscle-1/fibsem-uint8), the squeeze drops it to rank 2, but grid_scale still has 3 entries, so the second indexing op raises:
IndexError: Indexing expression requires 3 dimensions, and cannot be applied to a domain of rank 2
Repro:
from microsim.cosem import CosemDataset
img = CosemDataset.fetch("jrc_mus-skel-muscle-1").image(name="fibsem-uint8")
img.read(level=-1) # lowest level -> IndexError
Not zarr3-specific — any image whose lowest level collapses an axis would hit it.
Proposed fix
Squeeze the per-axis grid_scale slices the same way (drop entries for axes that were squeezed out), or skip squeezed axes when building the reversal slices, so the two indexing ops stay rank-consistent.
Small, low-priority bug found while adding zarr3 support (#140/#141).
Bug
read_tensorstore()squeezes singleton dims:then reverses axes based on
grid_scale:When the smallest pyramid level has an axis of size 1 (e.g.
s11ofjrc_mus-skel-muscle-1/fibsem-uint8), the squeeze drops it to rank 2, butgrid_scalestill has 3 entries, so the second indexing op raises:Repro:
Not zarr3-specific — any image whose lowest level collapses an axis would hit it.
Proposed fix
Squeeze the per-axis
grid_scaleslices the same way (drop entries for axes that were squeezed out), or skip squeezed axes when building the reversal slices, so the two indexing ops stay rank-consistent.