-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle fill_value datatype for string-array (#140)
* handle fill_value datatype for string-array * fix 0 -> '' * fix: minimise "string"/0 fill value workaround * chore: add V2 string fill value tests --------- Co-authored-by: Zhuoqing Fang <fangzq@KLG9H04WF3.local> Co-authored-by: Lachlan Deakin <ljdgit@gmail.com>
- Loading branch information
1 parent
9070e12
commit 20089c5
Showing
11 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env -S uv run | ||
# /// script | ||
# requires-python = ">=3.12" | ||
# dependencies = [ | ||
# "zarr==3.0.1", | ||
# ] | ||
# /// | ||
|
||
import zarr | ||
|
||
path_out = "tests/data/zarr_python_compat/str_v2_fv_0.zarr" | ||
array = zarr.create_array( | ||
path_out, | ||
dtype=str, | ||
shape=(5,), | ||
chunks=(2,), | ||
filters=zarr.codecs.vlen_utf8.VLenUTF8(), | ||
compressors=[None], | ||
fill_value=0, | ||
zarr_format=2, | ||
overwrite=True, | ||
) | ||
array[:3] = ["a", "bb", ""] | ||
print(array.info) | ||
# assert (array[:] == ["a", "bb", "", "", ""]).all() # FAILURE | ||
|
||
path_out = "tests/data/zarr_python_compat/str_v2_fv_null.zarr" | ||
array = zarr.create_array( | ||
path_out, | ||
dtype=str, | ||
shape=(5,), | ||
chunks=(2,), | ||
filters=zarr.codecs.vlen_utf8.VLenUTF8(), | ||
compressors=[None], | ||
fill_value=None, | ||
zarr_format=2, | ||
overwrite=True, | ||
) | ||
array[:3] = ["a", "bb", ""] | ||
print(array.info) | ||
print(array[:]) | ||
assert (array[:] == ["a", "bb", "", "", ""]).all() |
19 changes: 19 additions & 0 deletions
19
zarrs/tests/data/zarr_python_compat/str_v2_fv_0.zarr/.zarray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"shape": [ | ||
5 | ||
], | ||
"chunks": [ | ||
2 | ||
], | ||
"fill_value": 0, | ||
"order": "C", | ||
"filters": [ | ||
{ | ||
"id": "vlen-utf8" | ||
} | ||
], | ||
"dimension_separator": ".", | ||
"compressor": null, | ||
"zarr_format": 2, | ||
"dtype": "|O" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
zarrs/tests/data/zarr_python_compat/str_v2_fv_null.zarr/.zarray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"shape": [ | ||
5 | ||
], | ||
"chunks": [ | ||
2 | ||
], | ||
"fill_value": null, | ||
"order": "C", | ||
"filters": [ | ||
{ | ||
"id": "vlen-utf8" | ||
} | ||
], | ||
"dimension_separator": ".", | ||
"compressor": null, | ||
"zarr_format": 2, | ||
"dtype": "|O" | ||
} |
1 change: 1 addition & 0 deletions
1
zarrs/tests/data/zarr_python_compat/str_v2_fv_null.zarr/.zattrs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters