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)
| 211 | |
| 212 | |
| 213 | def 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 | |
| 233 | def has_zarr_async_index() -> bool: |
no outgoing calls
no test coverage detected
searching dependent graphs…