MCPcopy
hub / github.com/dask/dask / _check_regular_chunks

Function _check_regular_chunks

dask/array/core.py:4151–4188  ·  view source on GitHub ↗

Check if the chunks are regular "Regular" in this context means that along every axis, the chunks all have the same size, except the last one, which may be smaller Parameters ---------- chunkset: tuple of tuples of ints From the ``.chunks`` attribute of an ``Array``

(chunkset)

Source from the content-addressed store, hash-verified

4149
4150
4151def _check_regular_chunks(chunkset):
4152 """Check if the chunks are regular
4153
4154 "Regular" in this context means that along every axis, the chunks all
4155 have the same size, except the last one, which may be smaller
4156
4157 Parameters
4158 ----------
4159 chunkset: tuple of tuples of ints
4160 From the ``.chunks`` attribute of an ``Array``
4161
4162 Returns
4163 -------
4164 True if chunkset passes, else False
4165
4166 Examples
4167 --------
4168 >>> import dask.array as da
4169 >>> arr = da.zeros(10, chunks=(5, ))
4170 >>> _check_regular_chunks(arr.chunks)
4171 True
4172
4173 >>> arr = da.zeros(10, chunks=((3, 3, 3, 1), ))
4174 >>> _check_regular_chunks(arr.chunks)
4175 True
4176
4177 >>> arr = da.zeros(10, chunks=((3, 1, 3, 3), ))
4178 >>> _check_regular_chunks(arr.chunks)
4179 False
4180 """
4181 for chunks in chunkset:
4182 if len(chunks) == 1:
4183 continue
4184 if len(set(chunks[:-1])) > 1:
4185 return False
4186 if chunks[-1] > chunks[0]:
4187 return False
4188 return True
4189
4190
4191def from_delayed(value, shape, dtype=None, meta=None, name=None):

Callers 2

test_regular_chunksFunction · 0.90
to_zarrFunction · 0.85

Calls 1

setClass · 0.85

Tested by 1

test_regular_chunksFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…