zarrita.js icon indicating copy to clipboard operation
zarrita.js copied to clipboard

Cannot set scalar

Open ondave opened this issue 1 year ago • 1 comments

It does not appear to be possible to set a scalar 'array'. The zarr specification does apparently allow this with shape=[] and the read case is handled in https://github.com/manzt/zarrita.js/blob/main/packages/indexing/src/get.ts with this code: return indexer.shape.length === 0 ? unwrap(out.data, 0) : out;

However in https://github.com/manzt/zarrita.js/blob/main/packages/indexing/src/set.ts the zero length shape results in a zero length indexer which means nothing gets written to the array.

ondave avatar Oct 17 '24 02:10 ondave

Looking a bit more into this, is this related to the fact that the only way to represent a typed value suitable for writing to the array is a TypedArray? Which of course is an array! Without a TypedScalar equivalent, it is not so straightforward to set a scalar value. Setting a zarr array with a length 1 TypedArray works fine but is then represented in zarr as having shape [1].

ondave avatar Oct 17 '24 03:10 ondave