constraint

Constraint primitives and applicability constraints for distribution registry.

This module defines constraints used to determine whether certain computations or characteristics can be applied to specific distributions based on their features like kind, dimension, support, etc.

class pysatl_core.distributions.registry.constraint.Constraint(*args, **kwargs)[source]

Bases: Protocol

Protocol for value-level constraints.

allows(value)[source]

Check if the constraint allows the given value.

Return type:

bool

Parameters:

value (Any)

__init__(*args, **kwargs)
class pysatl_core.distributions.registry.constraint.NonNullConstraint[source]

Bases: object

Constraint that rejects None values.

allows(value)[source]

Return False if value is None, True otherwise.

Return type:

bool

Parameters:

value (Any)

__init__()
Return type:

None

class pysatl_core.distributions.registry.constraint.SetConstraint(allowed=None)[source]

Bases: object

Constraint that checks membership in a finite set.

Parameters:

allowed (frozenset[Any] | None) – The set of allowed values. If None, all values are allowed.

allowed: frozenset[Any] | None
allows(value)[source]

Check if the value is in the allowed set.

Returns:

True if allowed is None or value is in allowed, False otherwise.

Return type:

bool

Parameters:

value (Any)

__init__(allowed=None)
Parameters:

allowed (frozenset[Any] | None)

Return type:

None

class pysatl_core.distributions.registry.constraint.NumericConstraint(allowed=None, ge=None, le=None)[source]

Bases: object

Constraint for numeric values with bounds and/or allowed values.

Parameters:
  • allowed (frozenset[int] | None) – Specific allowed integer values.

  • ge (int | None) – Minimum allowed value (inclusive).

  • le (int | None) – Maximum allowed value (inclusive).

Notes

All conditions are combined with AND logic. For example, to restrict dimension to exactly 1: allowed=frozenset({1}). To require dimension to be at least 2: ge=2. To require dimension between 2 and 5: ge=2, le=5.

allowed: frozenset[int] | None
ge: int | None
le: int | None
allows(value)[source]

Check if the value satisfies all numeric constraints.

Returns:

True if value is an integer satisfying all constraints, False otherwise.

Return type:

bool

Parameters:

value (Any)

__init__(allowed=None, ge=None, le=None)
Parameters:
Return type:

None

class pysatl_core.distributions.registry.constraint.GraphPrimitiveConstraint(distribution_type_feature_constraints=<factory>, distribution_instance_feature_constraints=<factory>)[source]

Bases: object

Constraint that checks distribution features at type and instance levels.

This constraint evaluates whether a Distribution satisfies constraints based on both its DistributionType features and its own instance attributes.

Parameters:
  • distribution_type_feature_constraints (Mapping[str, Constraint]) – Constraints on distribution type features (e.g., kind, dimension). Features are read from the DistributionType object’s registry_features.

  • distribution_instance_feature_constraints (Mapping[str, Constraint]) – Constraints on distribution instance features (e.g., support). Features are read directly from the Distribution instance attributes.

distribution_type_feature_constraints: Mapping[str, Constraint]
distribution_instance_feature_constraints: Mapping[str, Constraint]
__post_init__()[source]

Wrap provided mappings into read-only proxies for immutability.

Return type:

None

allows(distr)[source]

Check if the distribution satisfies all constraints.

Parameters:

distr (Distribution) – The distribution to check.

Returns:

True if all constraints are satisfied, False otherwise.

Return type:

bool

Notes

Type features are read from distr.distribution_type.registry_features. Instance features are read directly from distr attributes.

__init__(distribution_type_feature_constraints=<factory>, distribution_instance_feature_constraints=<factory>)
Parameters:
Return type:

None