Skip to content

Commit

Permalink
sync metadata methods with current master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
grlee77 committed Oct 21, 2021
1 parent ca4db80 commit 15d4d78
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions zarr/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Metadata2:

@classmethod
def parse_metadata(cls, s: Union[MappingType, str]) -> MappingType[str, Any]:

# Here we allow that a store may return an already-parsed metadata object,
# or a string of JSON that we will parse here. We allow for an already-parsed
# object to accommodate a consolidated metadata store, where all the metadata for
Expand All @@ -24,9 +25,11 @@ def parse_metadata(cls, s: Union[MappingType, str]) -> MappingType[str, Any]:
if isinstance(s, Mapping):
# assume metadata has already been parsed into a mapping object
meta = s

else:
# assume metadata needs to be parsed as JSON
meta = json_loads(s)

return meta

@classmethod
Expand All @@ -40,13 +43,14 @@ def decode_array_metadata(cls, s: Union[MappingType, str]) -> MappingType[str, A

# extract array metadata fields
try:
# dimension_separator = meta.get("dimension_separator", None)
dtype = cls.decode_dtype(meta["dtype"])
if dtype.hasobject:
import numcodecs
object_codec = numcodecs.get_codec(meta['filters'][0])
else:
object_codec = None

dimension_separator = meta.get("dimension_separator", None)
fill_value = cls.decode_fill_value(meta['fill_value'], dtype, object_codec)
meta = dict(
zarr_format=meta["zarr_format"],
Expand All @@ -57,8 +61,9 @@ def decode_array_metadata(cls, s: Union[MappingType, str]) -> MappingType[str, A
fill_value=fill_value,
order=meta["order"],
filters=meta["filters"],
dimension_separator=meta.get("dimension_separator", "."),
)
if dimension_separator:
meta['dimension_separator'] = dimension_separator
except Exception as e:
raise MetadataError("error decoding metadata") from e
else:
Expand Down

0 comments on commit 15d4d78

Please sign in to comment.