(
size: int,
chunk_size: int,
region: slice | None = None,
)
| 132 | |
| 133 | |
| 134 | def build_grid_chunks( |
| 135 | size: int, |
| 136 | chunk_size: int, |
| 137 | region: slice | None = None, |
| 138 | ) -> tuple[int, ...]: |
| 139 | if region is None: |
| 140 | region = slice(0, size) |
| 141 | |
| 142 | region_start = region.start or 0 |
| 143 | # Generate the zarr chunks inside the region of this dim |
| 144 | chunks_on_region = [chunk_size - (region_start % chunk_size)] |
| 145 | if chunks_on_region[0] >= size: |
| 146 | # This is useful for the scenarios where the chunk_size are bigger |
| 147 | # than the variable chunks, which can happens when the user specifies |
| 148 | # the enc_chunks manually. |
| 149 | return (size,) |
| 150 | chunks_on_region.extend([chunk_size] * ((size - chunks_on_region[0]) // chunk_size)) |
| 151 | if (size - chunks_on_region[0]) % chunk_size != 0: |
| 152 | chunks_on_region.append((size - chunks_on_region[0]) % chunk_size) |
| 153 | return tuple(chunks_on_region) |
| 154 | |
| 155 | |
| 156 | def grid_rechunk( |
no outgoing calls
searching dependent graphs…