MCPcopy Index your code
hub / github.com/pydata/xarray / encode_zarr_attr_value

Function encode_zarr_attr_value

xarray/backends/zarr.py:213–230  ·  view source on GitHub ↗

Encode an attribute value as something that can be serialized as json Many xarray datasets / variables have numpy arrays and values. This function handles encoding / decoding of such items. ndarray -> list scalar array -> scalar other -> other (no change)

(value)

Source from the content-addressed store, hash-verified

211
212
213def encode_zarr_attr_value(value):
214 """
215 Encode an attribute value as something that can be serialized as json
216
217 Many xarray datasets / variables have numpy arrays and values. This
218 function handles encoding / decoding of such items.
219
220 ndarray -> list
221 scalar array -> scalar
222 other -> other (no change)
223 """
224 if isinstance(value, np.ndarray):
225 encoded = value.tolist()
226 elif isinstance(value, np.generic):
227 encoded = value.item()
228 else:
229 encoded = value
230 return encoded
231
232
233def has_zarr_async_index() -> bool:

Callers 1

encode_attributeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…