|
9 | 9 |
|
10 | 10 | import numpy as np
|
11 | 11 | import pandas as pd
|
| 12 | +from packaging.version import Version |
12 | 13 |
|
13 | 14 | from xarray import coding, conventions
|
14 | 15 | from xarray.backends.common import (
|
@@ -880,10 +881,24 @@ def open_store_variable(self, name):
|
880 | 881 | if zarr_array.fill_value is not None:
|
881 | 882 | attributes["_FillValue"] = zarr_array.fill_value
|
882 | 883 | elif "_FillValue" in attributes:
|
883 |
| - original_zarr_dtype = zarr_array.metadata.data_type |
884 |
| - attributes["_FillValue"] = FillValueCoder.decode( |
885 |
| - attributes["_FillValue"], original_zarr_dtype.value |
886 |
| - ) |
| 884 | + # TODO update version check for the released version with dtypes |
| 885 | + # probably be 3.1 |
| 886 | + import zarr |
| 887 | + |
| 888 | + if Version(zarr.__version__) >= Version("3.0.6"): |
| 889 | + attributes["_FillValue"] = ( |
| 890 | + # Use the new dtype infrastructure instead of doing xarray |
| 891 | + # specific fill value decoding |
| 892 | + zarr_array.metadata.data_type.from_json_value( |
| 893 | + attributes["_FillValue"], |
| 894 | + zarr_format=zarr_array.metadata.zarr_format, |
| 895 | + ) |
| 896 | + ) |
| 897 | + else: |
| 898 | + original_zarr_dtype = zarr_array.metadata.data_type |
| 899 | + attributes["_FillValue"] = FillValueCoder.decode( |
| 900 | + attributes["_FillValue"], original_zarr_dtype.value |
| 901 | + ) |
887 | 902 |
|
888 | 903 | return Variable(dimensions, data, attributes, encoding)
|
889 | 904 |
|
@@ -1132,10 +1147,6 @@ def _create_new_array(
|
1132 | 1147 | if c in encoding:
|
1133 | 1148 | encoding["config"][c] = encoding.pop(c)
|
1134 | 1149 |
|
1135 |
| - print(fill_value) |
1136 |
| - print(encoding) |
1137 |
| - print(dtype) |
1138 |
| - print(shape) |
1139 | 1150 | zarr_array = self.zarr_group.create(
|
1140 | 1151 | name,
|
1141 | 1152 | shape=shape,
|
|
0 commit comments