-
-
Notifications
You must be signed in to change notification settings - Fork 350
Description
I'm trying to update VirtualiZarr to work with the new data types, and just wanted to note some ways in which I found the new API confusing.
I briefly skimmed the narrative docs page, read the phrase "native dtypes", and then found a the zarr.dtype.ZDType.from_native_dtype()
constructor classmethod in the API docs. But that behaved very counterintuitively:
In [1]: from zarr.dtype import ZDType, parse_data_type
In [2]: import numpy as np
In [3]: np.dtype('int32')
Out[3]: dtype('int32')
In [4]: ZDType.from_native_dtype(np.dtype('int32'))
This returns None
?!
Looking at the docs more closely, apparently I would have to do Int32.from_native_dtype(np.dtype('int32'))
? But that's no help to me if I don't already have the zarr dtype.
I'm also confused as to why passing the base class succeeds at all. If Int32
is a subclass of ZDType
, and .from_native_dtype
is intended to be used on the subclasses, then why isn't it abstract on the base class?
It seems what I actually needed was parse_data_type
:
In [6]: parse_data_type(np.dtype('int32'), zarr_format=3)
Out[6]: Int32(endianness='little')
which isn't mentioned explicitly in the narrative docs, nor uses the word "native" anywhere, even though it seems to parse native dtypes.
After reading the full docs page, I still don't think it would be clear how to get from a native dtype to a zarr data type. Presumably that information should be part of the section on Data Type Resolution.
Aside: It's also confusing how the docs page says
Zarr V3 data types do not have endianness.
but that Int32(endianness='little')
object certainly seems to have endianess...
/ end rant 😅