q1ss.ap.base
Abstract base class for ordered affine partitions.
AP
- class AP(subsp_dim, ambient_dim)[source]
Bases:
ABCAbstract base class for ordered balanced affine partitions of
n-bitstrings.- __getitem__(label)[source]
Returns the affine subspace corresponding to the given label in this affine partition.
- Parameters:
- Return type:
- abstractmethod _get_subspace(label)[source]
Abstract method to be implemented by subclasses, providing the underlying logic for
__getitem__.Returns the affine subspace corresponding to the given label. The label vector has already been validated, and is guaranteed to have dimension equal to the
label_dimfor the partition.- Parameters:
label (
binvec)- Return type:
- _is_ortho(vec, label)[source]
Returns whether the given vector is orthogonal to the affine subspace corresponding to the given label in this affine partition, providing the underlying logic for
AP.is_ortho.The default implementation relies on producing the affine subspace and explicitly testing for orthogonality: subclasses can override this method to provide a more efficient implementation.
- _label(vec)[source]
Returns the label of the given vector in this affine partition, providing the underlying logic for
label.The default implementation works by brute force search over all affine subspaces: subclasses can override this method to provide a more efficient implementation.
- draw(axes, *, colors=None, label=None, subsp_kwargs=None, **draw_networkx_kwargs)[source]
Draws the affine partition using
draw_networkx.
- property explicit
Returns an explicit representation of this affine partition.
- Return type:
- is_ortho(vec, label)[source]
Returns whether the given vector is orthogonal to the affine subspace corresponding to the given label in this affine partition
- property label_dim
The dimension of the label vectors for subspaces in this partition
- Return type:
- validate(*, num_vecs=None, num_labels=None, rng=None)[source]
Validates the partition:
checks that all subspaces have the correct dimensions
checks that all pairs of distinct subspaces are disjoint
checks that all vectors belong to the subspace with associated label
checks that orthogonality relationships are correct
If
num_vecsandnum_labelsare not specified, the method will validate the partition using all possible vectors and labels, respectively. Otherwise, it will use the specified number of random vectors and labels.