File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -612,6 +612,7 @@ class DataType(Enum):
612
612
complex128 = "complex128"
613
613
string = "string"
614
614
bytes = "bytes"
615
+ example = "https://example.com"
615
616
616
617
@property
617
618
def byte_count (self ) -> int | None :
@@ -630,6 +631,7 @@ def byte_count(self) -> int | None:
630
631
DataType .float64 : 8 ,
631
632
DataType .complex64 : 8 ,
632
633
DataType .complex128 : 16 ,
634
+ DataType .example : 32 ,
633
635
}
634
636
try :
635
637
return data_type_byte_counts [self ]
@@ -657,9 +659,11 @@ def to_numpy_shortname(self) -> str:
657
659
DataType .float64 : "f8" ,
658
660
DataType .complex64 : "c8" ,
659
661
DataType .complex128 : "c16" ,
662
+ DataType .example : np .dtype (object ),
660
663
}
661
664
return data_type_to_numpy [self ]
662
665
666
+
663
667
def to_numpy (self ) -> np .dtypes .StringDType | np .dtypes .ObjectDType | np .dtype [Any ]:
664
668
# note: it is not possible to round trip DataType <-> np.dtype
665
669
# due to the fact that DataType.string and DataType.bytes both
Original file line number Diff line number Diff line change @@ -411,3 +411,18 @@ def test_dtypes(dtype_str: str) -> None:
411
411
else :
412
412
# return type for vlen types may vary depending on numpy version
413
413
assert dt .byte_count is None
414
+
415
+ async def test_ext_uri () -> None :
416
+ metadata_dict = {
417
+ "zarr_format" : 3 ,
418
+ "node_type" : "array" ,
419
+ "shape" : (1 ,),
420
+ "chunk_grid" : {"name" : "regular" , "configuration" : {"chunk_shape" : (1 ,)}},
421
+ "data_type" : "https://example.com" ,
422
+ "chunk_key_encoding" : {"name" : "default" , "separator" : "." },
423
+ "codecs" : [{"name" : "bytes" }],
424
+ "fill_value" : 0 ,
425
+ }
426
+ m = ArrayV3Metadata .from_dict (metadata_dict )
427
+ d = json .loads (m .to_buffer_dict (default_buffer_prototype ())["zarr.json" ].to_bytes ())
428
+ assert m .data_type is DataType .example
You can’t perform that action at this time.
0 commit comments