zarr-developers / community

An open community with an interest in developing and using new technologies for tensor data storage.
19 stars 1 forks source link

Best practices when reading zarr arrays in languages with limited support for data types. #25

Open gdkrmr opened 4 years ago

gdkrmr commented 4 years ago

I am working on an R package to read Zarr arrays. What is the best behavior when reading in data types that are not supported by the language?

E.g. R does not have an 64 bit integer, only float64 and int32. Currently I just convert the the 64 bit integer into a 64 bit float. What would be best practice?

meggart commented 4 years ago

This has probably affected Zarr.js as well, maybe @gzuidhof can share experiences?

gzuidhof commented 4 years ago

I don't know about best practices, but in the browser we can't read represent numbers larger than ~ 2^53. In some modern browsers (Chrome, FF) its actually possible (see this part of the docs), but I chose not to include support for it by default.

Nobody has asked for it yet, adding support for it would be a matter of a couple of lines here and there, I guess it's a matter of time that we do add it.

I personally think the right thing is to warn when opening a zarr array with int64 type, allow the user to specify what type to downcast to explicitly (float64 or int32), when they do specify it explicitly don't show the warning, and finally throw an error when conversion fails.

h-mayorquin commented 5 months ago

Maybe now it could be implemented now?

https://caniuse.com/?search=BigInt64Array