| 243 | __slots__ = ("_array", "dtype", "shape") |
| 244 | |
| 245 | def __init__(self, zarr_array): |
| 246 | # some callers attempt to evaluate an array if an `array` property exists on the object. |
| 247 | # we prefix with _ to avoid this inference. |
| 248 | |
| 249 | # TODO type hint this? |
| 250 | self._array = zarr_array |
| 251 | self.shape = self._array.shape |
| 252 | |
| 253 | # preserve vlen string object dtype (GH 7328) |
| 254 | if ( |
| 255 | not _zarr_v3() |
| 256 | and self._array.filters is not None |
| 257 | and any(filt.codec_id == "vlen-utf8" for filt in self._array.filters) |
| 258 | ) or ( |
| 259 | _zarr_v3() |
| 260 | and self._array.serializer |
| 261 | and self._array.serializer.to_dict()["name"] == "vlen-utf8" |
| 262 | ): |
| 263 | dtype = coding.strings.create_vlen_dtype(str) |
| 264 | else: |
| 265 | dtype = self._array.dtype |
| 266 | |
| 267 | self.dtype = dtype |
| 268 | |
| 269 | def get_array(self): |
| 270 | return self._array |