|
1 |
| -import warnings |
2 |
| - |
3 | 1 | import numpy as np
|
4 | 2 |
|
5 | 3 | from .. import coding, conventions
|
@@ -368,53 +366,6 @@ def encode_variable(self, variable):
|
368 | 366 | def encode_attribute(self, a):
|
369 | 367 | return encode_zarr_attr_value(a)
|
370 | 368 |
|
371 |
| - @staticmethod |
372 |
| - def get_chunk(name, var, chunks): |
373 |
| - chunk_spec = dict(zip(var.dims, var.encoding.get("chunks"))) |
374 |
| - |
375 |
| - # Coordinate labels aren't chunked |
376 |
| - if var.ndim == 1 and var.dims[0] == name: |
377 |
| - return chunk_spec |
378 |
| - |
379 |
| - if chunks == "auto": |
380 |
| - return chunk_spec |
381 |
| - |
382 |
| - for dim in var.dims: |
383 |
| - if dim in chunks: |
384 |
| - spec = chunks[dim] |
385 |
| - if isinstance(spec, int): |
386 |
| - spec = (spec,) |
387 |
| - if isinstance(spec, (tuple, list)) and chunk_spec[dim]: |
388 |
| - if any(s % chunk_spec[dim] for s in spec): |
389 |
| - warnings.warn( |
390 |
| - "Specified Dask chunks %r would " |
391 |
| - "separate Zarr chunk shape %r for " |
392 |
| - "dimension %r. This significantly " |
393 |
| - "degrades performance. Consider " |
394 |
| - "rechunking after loading instead." |
395 |
| - % (chunks[dim], chunk_spec[dim], dim), |
396 |
| - stacklevel=2, |
397 |
| - ) |
398 |
| - chunk_spec[dim] = chunks[dim] |
399 |
| - return chunk_spec |
400 |
| - |
401 |
| - @classmethod |
402 |
| - def maybe_chunk(cls, name, var, chunks, overwrite_encoded_chunks): |
403 |
| - chunk_spec = cls.get_chunk(name, var, chunks) |
404 |
| - |
405 |
| - if (var.ndim > 0) and (chunk_spec is not None): |
406 |
| - from dask.base import tokenize |
407 |
| - |
408 |
| - # does this cause any data to be read? |
409 |
| - token2 = tokenize(name, var._data, chunks) |
410 |
| - name2 = f"xarray-{name}-{token2}" |
411 |
| - var = var.chunk(chunk_spec, name=name2, lock=None) |
412 |
| - if overwrite_encoded_chunks and var.chunks is not None: |
413 |
| - var.encoding["chunks"] = tuple(x[0] for x in var.chunks) |
414 |
| - return var |
415 |
| - else: |
416 |
| - return var |
417 |
| - |
418 | 369 | def store(
|
419 | 370 | self,
|
420 | 371 | variables,
|
|
0 commit comments