q1ss.ap.explicit

Explicitly specified affine partitions.

ExplicitAP

final class ExplicitAP(subspaces)[source]

Bases: AP

Class for ordered balanced affine partitions of n-bitstrings explicitly specified by a complete family of disjoint affine subspaces.

static __new__(cls, subspaces)[source]

Creates a new explicit affine partition from the given sequence of disjoint affine subspaces.

Parameters:

subspaces (Sequence[AffineSubspace])

Return type:

Self

_get_subspace(label)[source]

Returns the affine subspace corresponding to the given label, providing the underlying logic for __getitem__.

The desired subspace is accessed from internal memory and returned.

Parameters:

label (binvec)

Return type:

AffineSubspace

static random(subsp_dim, ambient_dim, *, rng=None)[source]

Samples a random affine partition with given subspace and ambient dimensions.

Sampling random affine partitions is an expensive operation in general, and the running time grows exponentially with the ambient dimension.

Warning

This method relies on random to sample subspaces, which does not result in a uniform distribution over affine partitions. This will change in future releases.

Warning

The current implementation of this method is by rejection sampling, so it can be very slow even for small number of affine subspaces. This will change in future releases.

Parameters:
  • subsp_dim (int)

  • ambient_dim (int)

  • rng (np.random.Generator | int | None)

Return type:

ExplicitAP