tanat.sequence.type.state package#
Submodules#
tanat.sequence.type.state.entity module#
State entity implementation.
- class tanat.sequence.type.state.entity.StateEntity(id_value, store: str | Path | SequenceStore, features: list[str] | None = None, *, rank: int, store_index: int, cast_recipe: SequenceCastRecipe | dict | None = None, virtual_id: str | None = None, parent_metadata: SequenceMetadata | None = None)[source]#
Bases:
EntityEntity representing one state row (start/end).
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.
tanat.sequence.type.state.pool module#
State sequence pool implementation.
- class tanat.sequence.type.state.pool.StateSequencePool(store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None, cast_recipe: SequenceCastRecipe | dict | None = None)[source]#
Bases:
SequencePoolPool of state sequences.
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.
- SETTINGS_CLASS[source]#
alias of
StateSequenceSettings
- __init__(store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None, cast_recipe: SequenceCastRecipe | dict | None = None) None[source]#
Create a state sequence pool backed by store.
- Parameters:
store – Store path, name, or
SequenceStoreinstance.id_column – User-facing name for the sequence ID column.
start_column – User-facing name for the state start column.
end_column – User-facing name for the state end column.
entity_features – Subset of entity feature names to expose.
None→ all available from the store.static_features – Static feature names to expose.
None→ all available.[]→ none.cast_recipe – Optional cast recipe (or dict) applied at read time. Normalised via
SequenceCastRecipe.coerce()and probed eagerly.
- Raises:
TypeError – If cast_recipe is not a
SequenceCastRecipe,dict, orNone.
- as_event(anchor: Literal['start', 'end', 'middle'], *, time_column: str = 'time', destination: str | Path | None = None, overwrite: bool = False) EventSequencePool[source]#
Convert this state pool to an event pool by anchoring to one timestamp.
- Parameters:
anchor –
"start","end", or"middle"- selects which timestamp (or their midpoint) becomes the event timestamp.time_column – User-facing name for the event timestamp. Defaults to
"time".destination –
None→ ephemeral result; path → new persistent store.overwrite – Replace destination if it already exists.
- Returns:
A new
EventSequencePool.
- as_interval(*, start_column: str | None = None, end_column: str | None = None, destination: str | Path | None = None, overwrite: bool = False) IntervalSequencePool[source]#
Convert this state pool to an interval pool.
States and intervals share the same
(_t_start, _t_end)physical layout - no temporal recomputation needed.- Parameters:
start_column – User-facing name for the start column.
Noneinherits this pool’s current setting.end_column – User-facing name for the end column.
Noneinherits this pool’s current setting.destination –
None→ ephemeral result; path → new persistent store.overwrite – Replace destination if it already exists.
- Returns:
A new
IntervalSequencePool.
- as_state() StateSequencePool[source]#
Return this pool unchanged - source and target types are identical.
A warning is emitted to signal the no-op conversion.
- Returns:
self(no copy, no I/O).
- classmethod builder(*, end_value: datetime | int | float | None = None, validate_continuity: bool = True) StateSequenceStoreBuilder[source]#
Return a fluent builder for constructing a state sequence store.
- Parameters:
end_value – Sentinel for
T_ENDof the last state in each sequence whenend_columnis not provided at source registration time.None→ leaves the lastT_ENDasnull.validate_continuity – When
end_columnis provided, verify that states are truly contiguous (T_END[i] == T_START[i+1]) before writing. Defaults toTrue. Set toFalseon large datasets where the cost of a fullcollect()is unacceptable.
tanat.sequence.type.state.sequence module#
State sequence implementation.
- class tanat.sequence.type.state.sequence.StateSequence(id_value, store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None)[source]#
Bases:
SequenceA single state sequence.
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.
- SETTINGS_CLASS[source]#
alias of
StateSequenceSettings
- __init__(id_value, store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None) None[source]#
Create a state sequence for id_value.
- Parameters:
id_value – Sequence identifier.
store – Store path, name, or
SequenceStoreinstance.id_column – User-facing name for the sequence ID column.
start_column – User-facing name for the state start column.
end_column – User-facing name for the state end column.
entity_features – Subset of entity feature names to expose.
None→ all available from the store.static_features – Static feature names to expose.
None→ all available.[]→ none.
tanat.sequence.type.state.settings module#
State sequence settings.
- class tanat.sequence.type.state.settings.StateSequenceSettings(*, id_column: str, entity_features: list[str], static_features: list[str] = <factory>, start_column: str, end_column: str)[source]#
Bases:
SequenceSettingsSettings for state sequences (start + end timestamp columns).
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.
Module contents#
State sequence subtypes.
- class tanat.sequence.type.state.StateEntity(id_value, store: str | Path | SequenceStore, features: list[str] | None = None, *, rank: int, store_index: int, cast_recipe: SequenceCastRecipe | dict | None = None, virtual_id: str | None = None, parent_metadata: SequenceMetadata | None = None)[source]#
Bases:
EntityEntity representing one state row (start/end).
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.
- class tanat.sequence.type.state.StateSequence(id_value, store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None)[source]#
Bases:
SequenceA single state sequence.
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.
- SETTINGS_CLASS[source]#
alias of
StateSequenceSettings
- __init__(id_value, store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None) None[source]#
Create a state sequence for id_value.
- Parameters:
id_value – Sequence identifier.
store – Store path, name, or
SequenceStoreinstance.id_column – User-facing name for the sequence ID column.
start_column – User-facing name for the state start column.
end_column – User-facing name for the state end column.
entity_features – Subset of entity feature names to expose.
None→ all available from the store.static_features – Static feature names to expose.
None→ all available.[]→ none.
- class tanat.sequence.type.state.StateSequencePool(store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None, cast_recipe: SequenceCastRecipe | dict | None = None)[source]#
Bases:
SequencePoolPool of state sequences.
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.
- SETTINGS_CLASS[source]#
alias of
StateSequenceSettings
- __init__(store: str | Path | SequenceStore, *, id_column: str = 'id', start_column: str = 'start', end_column: str = 'end', entity_features: list[str] | None = None, static_features: list[str] | None = None, cast_recipe: SequenceCastRecipe | dict | None = None) None[source]#
Create a state sequence pool backed by store.
- Parameters:
store – Store path, name, or
SequenceStoreinstance.id_column – User-facing name for the sequence ID column.
start_column – User-facing name for the state start column.
end_column – User-facing name for the state end column.
entity_features – Subset of entity feature names to expose.
None→ all available from the store.static_features – Static feature names to expose.
None→ all available.[]→ none.cast_recipe – Optional cast recipe (or dict) applied at read time. Normalised via
SequenceCastRecipe.coerce()and probed eagerly.
- Raises:
TypeError – If cast_recipe is not a
SequenceCastRecipe,dict, orNone.
- as_event(anchor: Literal['start', 'end', 'middle'], *, time_column: str = 'time', destination: str | Path | None = None, overwrite: bool = False) EventSequencePool[source]#
Convert this state pool to an event pool by anchoring to one timestamp.
- Parameters:
anchor –
"start","end", or"middle"- selects which timestamp (or their midpoint) becomes the event timestamp.time_column – User-facing name for the event timestamp. Defaults to
"time".destination –
None→ ephemeral result; path → new persistent store.overwrite – Replace destination if it already exists.
- Returns:
A new
EventSequencePool.
- as_interval(*, start_column: str | None = None, end_column: str | None = None, destination: str | Path | None = None, overwrite: bool = False) IntervalSequencePool[source]#
Convert this state pool to an interval pool.
States and intervals share the same
(_t_start, _t_end)physical layout - no temporal recomputation needed.- Parameters:
start_column – User-facing name for the start column.
Noneinherits this pool’s current setting.end_column – User-facing name for the end column.
Noneinherits this pool’s current setting.destination –
None→ ephemeral result; path → new persistent store.overwrite – Replace destination if it already exists.
- Returns:
A new
IntervalSequencePool.
- as_state() StateSequencePool[source]#
Return this pool unchanged - source and target types are identical.
A warning is emitted to signal the no-op conversion.
- Returns:
self(no copy, no I/O).
- classmethod builder(*, end_value: datetime | int | float | None = None, validate_continuity: bool = True) StateSequenceStoreBuilder[source]#
Return a fluent builder for constructing a state sequence store.
- Parameters:
end_value – Sentinel for
T_ENDof the last state in each sequence whenend_columnis not provided at source registration time.None→ leaves the lastT_ENDasnull.validate_continuity – When
end_columnis provided, verify that states are truly contiguous (T_END[i] == T_START[i+1]) before writing. Defaults toTrue. Set toFalseon large datasets where the cost of a fullcollect()is unacceptable.
- class tanat.sequence.type.state.StateSequenceSettings(*, id_column: str, entity_features: list[str], static_features: list[str] = <factory>, start_column: str, end_column: str)[source]#
Bases:
SequenceSettingsSettings for state sequences (start + end timestamp columns).
States are contiguous and non-overlapping: the end of one state is always the start of the next, with no gaps in between.