Property
phasic.Property(name, max_value, min_value=0, offset=0)Defines a single property in a state space.
A property represents one dimension of the lineage state (e.g., number of descendants, population label, derived allele status). Each property has a name and min/max values for validation and encoding.
Parameters
name :str-
Property name (e.g., ‘descendants’, ‘population’)
max_value :int-
Maximum value this property can take
min_value :int= 0-
Minimum value this property can take (default 0)
offset :int= 0-
Deprecated: Use min_value instead. Minimum value offset (default 0).
Examples
>>> # Number of descendants (0 to sample_size)
>>> prop = Property('descendants', max_value=10)
>>> prop.validate_value(5) # OK
>>> prop.validate_value(11) # ValueError>>> # Population label (1 to n_populations)
>>> prop = Property('population', max_value=2, min_value=1)
>>> prop.validate_value(1) # OK
>>> prop.validate_value(0) # ValueErrorAttributes
| Name | Description |
|---|---|
| base | Radix base for mixed-radix system: max_value - min_value + 1. |
| min_value | int([x]) -> integer |
| offset | int([x]) -> integer |
Methods
| Name | Description |
|---|---|
| decode_value | Decode a state vector element to property value (add min_value). |
| encode_value | Encode a property value to state vector element (subtract min_value). |
| validate_value | Validate that a property value is in the valid range. |
decode_value
phasic.Property.decode_value(encoded)Decode a state vector element to property value (add min_value).
Parameters
encoded :int-
State vector element value (0-based offset)
Returns
:int-
Property value (with min_value applied)
encode_value
phasic.Property.encode_value(value)Encode a property value to state vector element (subtract min_value).
Parameters
value :int-
Property value to encode
Returns
:int-
State vector element value (0-based offset from min_value)
validate_value
phasic.Property.validate_value(value)Validate that a property value is in the valid range.
Parameters
value :int-
Value to validate
Raises
:ValueError-
If value is out of range [min_value, max_value]