chunkblocks.models

Module Contents

chunkblocks.models.all_borders(dimensions)[source]
chunkblocks.models.sub(slice_left, slice_right)[source]

Removes the right slice from the left. Does NOT account for slices on the right that do not touch the border of the left

class chunkblocks.models.Chunk(block, unit_index)[source]

Bases:object

__slots__ = ['unit_index', 'slices', 'offset', 'data', 'all_borders', 'block']
overlap
shape
squeeze_slices(self, slices)[source]

Ensure that the slices match the maximum permissible bounds of this particular chunk. Used for datasources that are unable to pad or handle out of bounds arrays properly

match_datasource_dimensions(self, datasource, slices)[source]
load_data(self, datasource, slices=None)[source]
dump_data(self, datasource, slices=None)[source]
copy_data(self, source, destination, slices=None)[source]
__eq__(self, other)[source]
__hash__(self)[source]
core_slices(self, borders=None)[source]

Returns a list of non-intersecting slices that is excluded by the requested borders. Borders is a list of tuples:

(dimension index of border, border direction)

Border direction is specified by -1 to represent the border in the negative index direction and +1 for the positive index direction.

border_slices(self, borders=None, nonintersecting=True)[source]

Returns a list of slices that cover the requested borders.

Parameters:borders – list of tuples indicating (dimension index of border, border direction)

When no borders are given, return all borders. Border direction is specified by -1 to represent the border in the negative index direction and +1 for the positive index direction. :param nonintersecting: if set to False, will return slices that will account for each index only once. if set to True, will indescriminately return the largest slices that will include the corners and edges more than once.

class chunkblocks.models.Block(bounds=None, offset=None, num_chunks=None, chunk_shape=None, overlap=None, base_iterator=None)[source]

Bases:object

unit_index_to_slices(self, index)[source]
chunk_slices_to_unit_index(self, slices)[source]

Get the corresponding chunk index for this chunk_slice

slices_to_unit_indices(self, slices)[source]

Get the corresponding unit indices that cover these slices

slices_to_chunks(self, slices)[source]

Get the corresponding chunks that cover these slices

static verify_size(num_chunks, chunk_shape, shape, overlap)[source]
ensure_checkpoint_stage(self, stage)[source]
checkpoint(self, chunk, stage=0)[source]
get_all_neighbors(self, chunk)[source]
is_checkpointed(self, chunk, stage=0)[source]
all_neighbors_checkpointed(self, chunk, stage=0)[source]
all_checkpointed(self, chunks, stage=0)[source]
chunk_iterator(self, start=None)[source]
core_slices(self, chunk)[source]

Returns the slices of the chunk that corresponds to the block’s core that has no overlap with other blocks.

overlap_borders(self, chunk)[source]

Get a list of borders in the chunk that correspond to the block’s overlap region.

Returns list of borders in the form of tuples:
(dimension index of border, border direction)

Border direction is specified by -1 to represent the border in the negative index direction and +1 for the positive index direction.

See py:method::overlap_slices(chunk) for usage

remove_chunk_overlap(self, chunk, overlapped_slices)[source]

Modify slices to remove the common intersection of the chunks within the block. Common intersections are excluded in a index first fashion, i.e. the slices do not include the portion of the data that will be accounted for by the next chunk ( next chunk is of a greater index ).

See py:method::overlap_slices_with_borders(chunk) for usage

overlap_slices(self, chunk)[source]

Get a list of the slices in the chunk that correspond to the block’s overlap region (i.e. the borders of the block) with chunk overlaps removed.

See py:method::overlap_slices(chunk) for more details

overlap_chunk_slices(self, chunk)[source]

Get a list of the all the chunks overlaps with overlaps across chunks accounted for only once.

See py:method::overlap_slices_with_borders(chunk, borders) for more details

overlap_slices_with_borders(self, chunk, borders)[source]

Get a list of the slices in the chunk that correspond the input borders with chunk overlaps removed.

If we have a block:
dimensions: 7x7 chunk_shape: 3x3 overlap: 1x1

This should result in 3x3 chunks. When this function is called with each of these chunks, slices that cover the overlap region are returned with no duplicates. Additionally, overlaps across chunks are excluded in a index first fashion, i.e. the slices do not include the portion of the data that had should be accounted for by the next chunk ( next chunk meaning of a greater index ).

At the non corner chunks, we expect to return a single tuple of slices that cover the overlap region, i.e.(not actual format, dictionary used for clarity)

x: slice(0, 1), y: slice(2, 5)

For corner chunks, this takes care of overlapping areas so they do not get counted twice. For example, for the chunk at position (0, 0), we should expect to return the tuples of slices:

x1: slice(0, 3), y1: slice(0, 1) x2: slice(0, 1), y2: slice(1, 3)]

WARNING: not tested for dimensions > 3.