sweetpea.base_constraint module

This module provides the base constraint class.

class sweetpea.base_constraint.Constraint

Bases: abc.ABC

Generic interface for constraints.

abstract validate(block)

Constraints can’t be completely validated in isolation. This function will be called on all constraints with the block during the block initialization to ensure all constraints are valid.

Return type

None

abstract apply(block, backend_request)
Return type

None

desugar()

Some constraints accept shorthand representations. (Like accepting a whole factor, rather than individual factor and level name pairs.)

Constraint.desugar() is responsible for returning the desugared representation of a constraint. When a block is constructed, it will desugar all constraints, replacing them with their desuagared versions before proceding.

Return type

List