MCPcopy Create free account
hub / github.com/dask/dask / _check_regular_chunks

Function _check_regular_chunks

dask/array/core.py:4146–4183  ·  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

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