dye_blot module

class dye_blot.DyeBlot(grid_dims, cell_dims)[source]

Bases: object

for_each_cell(function)[source]

Calls function(x, y) for each cell in the blot.

Args:
function: A callable object.
num_cells()[source]

Returns the number of cells in the blot.

dye_blot.make_blot(grid_dims, cell_dims, req_num_cells, permitted=None, squeeze=False)[source]

Create a DyeBlot on a given grid, perhaps enforcing a mask.

If permitted is specified, only cells for which permitted has a truthy value will be selected. If squeeze is True, non-permitted cells will simply be removed from consideration when extending a blot; if it is False, blot construction will be stopped and None returned if a non-permitted cell is used.

Args:

grid_dims (List): A 2-element list with width and height of the grid, in that order.

cell_dims (List): A 2-element list with width and height off the cells, in that order.

req_num_cells (Int): The required size of the blot.

permitted (np.ndarray): A 2D array of size corresponding to grid_dims.

Returns:
(Union[DyeBlot, None]) The constructed DyeBlot, or None if squeeze is False and a masked cell was used.