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:
ProtocolProtocol for value-level constraints.
- allows(value)[source]
Check if the constraint allows the given value.
- Return type:
- Parameters:
value (Any)
- __init__(*args, **kwargs)
- class pysatl_core.distributions.registry.constraint.NonNullConstraint[source]
Bases:
objectConstraint that rejects None values.
- __init__()
- Return type:
None
- class pysatl_core.distributions.registry.constraint.SetConstraint(allowed=None)[source]
Bases:
objectConstraint that checks membership in a finite set.
- Parameters:
allowed (
frozenset[Any] | None) – The set of allowed values. If None, all values are allowed.
- class pysatl_core.distributions.registry.constraint.NumericConstraint(allowed=None, ge=None, le=None)[source]
Bases:
objectConstraint 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.
- class pysatl_core.distributions.registry.constraint.GraphPrimitiveConstraint(distribution_type_feature_constraints=<factory>, distribution_instance_feature_constraints=<factory>)[source]
Bases:
objectConstraint 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:
- 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:
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:
distribution_type_feature_constraints (Mapping[str, Constraint])
distribution_instance_feature_constraints (Mapping[str, Constraint])
- Return type:
None