-
-
Notifications
You must be signed in to change notification settings - Fork 331
(fix): structured arrays for v2 #2681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d46de84
2090b98
f3e2e2d
a8d473b
7898ef8
9120425
9c2efdd
647868c
0b207a7
b2071a7
d19e968
ff730a3
89cc8d9
9c59167
7f64bab
b67acb9
3e050e7
7141de5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,7 +193,14 @@ def to_dict(self) -> dict[str, JSON]: | |
zarray_dict["fill_value"] = fill_value | ||
|
||
_ = zarray_dict.pop("dtype") | ||
zarray_dict["dtype"] = self.dtype.str | ||
dtype_json: JSON | ||
# In the case of zarr v2, the simplest i.e., '|VXX' dtype is represented as a string | ||
dtype_descr = self.dtype.descr | ||
if self.dtype.kind == "V" and dtype_descr[0][0] != "" and len(dtype_descr) != 0: | ||
dtype_json = tuple(self.dtype.descr) | ||
else: | ||
dtype_json = self.dtype.str | ||
Comment on lines
+197
to
+202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my attempt to match the old behavior. I didn't look back at the old code yet, but if someone knows this to be wrong, would be great to know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks right to me |
||
zarray_dict["dtype"] = dtype_json | ||
|
||
return zarray_dict | ||
|
||
|
@@ -220,6 +227,8 @@ def update_attributes(self, attributes: dict[str, JSON]) -> Self: | |
|
||
|
||
def parse_dtype(data: npt.DTypeLike) -> np.dtype[Any]: | ||
if isinstance(data, list): # this is a valid _VoidDTypeLike check | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any iterable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to handle the This might require more stringent checking or tests...Not sure. The reason this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the dtype constructor would make an exception (or our own comprehension fails) in the case the JSON on disk was edited - so I'm not too worried. |
||
data = [tuple(d) for d in data] | ||
return np.dtype(data) | ||
|
||
|
||
|
@@ -376,8 +385,10 @@ def _default_filters( | |
dtype_key = "numeric" | ||
elif dtype.kind in "U": | ||
dtype_key = "string" | ||
elif dtype.kind in "OSV": | ||
elif dtype.kind in "OS": | ||
dtype_key = "bytes" | ||
elif dtype.kind == "V": | ||
dtype_key = "raw" | ||
else: | ||
raise ValueError(f"Unsupported dtype kind {dtype.kind}") | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.