Open CarlAndersson opened 1 day ago
Do we want to have arbitrary python objects stored in attrs
? We serialize to json so arguably need to constrain ourselves to types that are JSON-compatible...
the question is, would zarr
be able to store datetimes without encoding? If so, I believe it may be possible to extend the zarr
backend specifically to allow this (though not sure if that would make the encoding machinery too complicated?).
We could ofc serialize and deserialize into our own propriety format. But I'm not sure what the interface would be?
In this case I was just wondering whether we can get away with not serializing datetimes at all (but only for the zarr
backend, if the zarr
format supports this).
I agree that serializing attributes might be useful (see the many CRS representations, for example) but potentially too complex at this point. Also, a custom format convention both means a lot of work and won't be compatible with other libraries, especially from other languages.
What happened?
I have a dataset with an attribute which is a time, stored as a np.datetime64 value with nanosecond precision. Saving this to a zarr store and loading the dataset again drops the type of this attribute and loads it as an integer.
Example dataset:
gets loaded back as
Using second precision for the datetime64 (instead of nanosecond) raises an error on json serialization, since it gets converted into a datetime at some point.
What did you expect to happen?
The time gets stored and read back properly.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment