binpack#
- class Block(id: str, width: int, height: int, dependencies: list[Block] | None = None)#
Bases:
object- norm() float#
- class Node(origin: tuple[int, int], size: tuple[int, int])#
Bases:
objectDefines an object Node for use in the packer function. Represents the space that a block is placed.
- Parameters:
size – The width and height of the node.
origin – (x, y) coordinate of the top left of the node.
- used#
Boolean to determine if a node has been used.
- down#
A node located beneath the current node.
- right#
A node located to the right of the current node.
- class Bin(blocks: Sequence[Block] | None = None, width: int | None = None)#
Bases:
object- clear() None#
- norm() float#
- pack_by_count_atomic(blocks: Sequence[Block], count: int = 8) list[Bin]#
Partition blocks into
countblocks.A note on the value of
count:If
count == ONE_PER_BIN, tests are put into individual batchesIf
count == AUTO, tests are put into batches automaticallyIf
count >= 1, tests are put into at mostcountbatches, though it may be less.
- pack_by_count(blocks: Sequence[Block], count: int = 8, grouper: Callable[[Sequence[Block]], list[list[Block]]] | None = None) list[Bin]#
Pack blocks into
countbins such that each bin has no intra-dependencies. Bin can depend on other bins.A note on the value of
count:If
count == ONE_PER_BIN, tests are put into individual batchesIf
count == AUTO, tests are batched such that each batch contains no inter-batch dependenciesIf
count >= 1, tests are put into at mostcountbatches, though it may be less.
- pack_to_height(blocks: Sequence[Block], height: int = 1800, width: int | None = None, grouper: Callable[[Sequence[Block]], list[list[Block]]] | None = None) list[Bin]#
Partition blocks by tiling in the 2D space defined by width x height
- groupby_dep(blocks: Sequence[Block]) list[set[Block]]#
Group jobs such that a job and any of its dependencies are in the same group