tanat.sequence.type package#
Subpackages#
- tanat.sequence.type.event package
- tanat.sequence.type.interval package
- tanat.sequence.type.state package
Module contents#
Sequence subtypes.
- class tanat.sequence.type.EventEntity(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 event row (single timestamp).
- class tanat.sequence.type.EventSequence(id_value, store: str | Path | SequenceStore, *, id_column: str = 'id', time_column: str = 'time', entity_features: list[str] | None = None, static_features: list[str] | None = None)[source]#
Bases:
SequenceA single event sequence (one timestamp per entity row).
- SETTINGS_CLASS[source]#
alias of
EventSequenceSettings
- __init__(id_value, store: str | Path | SequenceStore, *, id_column: str = 'id', time_column: str = 'time', entity_features: list[str] | None = None, static_features: list[str] | None = None) None[source]#
Create an event 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.
time_column – User-facing name for the event timestamp 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.EventSequencePool(store: str | Path | SequenceStore, *, id_column: str = 'id', time_column: str = 'time', entity_features: list[str] | None = None, static_features: list[str] | None = None, cast_recipe: SequenceCastRecipe | dict | None = None)[source]#
Bases:
SequencePoolPool of event sequences (single timestamp per entity row).
- SETTINGS_CLASS[source]#
alias of
EventSequenceSettings
- __init__(store: str | Path | SequenceStore, *, id_column: str = 'id', time_column: str = 'time', entity_features: list[str] | None = None, static_features: list[str] | None = None, cast_recipe: SequenceCastRecipe | dict | None = None) None[source]#
Create an event sequence pool backed by store.
- Parameters:
store – Store path, name, or
SequenceStoreinstance.id_column – User-facing name for the sequence ID column.
time_column – User-facing name for the event timestamp 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() EventSequencePool[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).
- as_interval(duration: Duration, *, start_column: str = 'start', end_column: str = 'end', destination: str | Path | None = None, overwrite: bool = False) IntervalSequencePool[source]#
Convert this event pool to an interval pool by computing
_t_end.Each event timestamp becomes
_t_start;_t_endis computed as_t_start + duration. The resulting time index is stored as a virtual override (ephemeral) or written to a new persistent store.- Parameters:
duration –
Interval length added to each event timestamp. Can be:
A
timedeltaor numeric scalar: applied uniformly to every event.A
str: name of an entity feature column whose values provide per-row durations.
start_column – User-facing name for the start column. Defaults to
"start".end_column – User-facing name for the end column. Defaults to
"end".destination –
None→ ephemeral result; path → new persistent store.overwrite – Replace destination if it already exists.
- Returns:
A new
IntervalSequencePool.
- as_state(*, end_value: datetime | int | float | str | None = None, start_column: str = 'start', end_column: str = 'end', destination: str | Path | None = None, overwrite: bool = False) StateSequencePool[source]#
Convert this event pool to a state pool by computing
_t_end.Each event timestamp becomes
_t_start;_t_endis taken from the next event in the same sequence (shift(-1).over(_seq_id)).- Parameters:
end_value – Sentinel for
_t_endof the last event per sequence.Noneleaves the last row with_t_end = null. Astrnames a static feature column whose per-sequence value fills the last_t_end.start_column – User-facing name for the start column. Defaults to
"start".end_column – User-facing name for the end column. Defaults to
"end".destination –
None→ ephemeral result; path → new persistent store.overwrite – Replace destination if it already exists.
- Returns:
A new
StateSequencePool.
- classmethod builder() EventSequenceStoreBuilder[source]#
Return a fluent builder for constructing an event sequence store.
- class tanat.sequence.type.EventSequenceSettings(*, id_column: str, entity_features: list[str], static_features: list[str] = <factory>, time_column: str)[source]#
Bases:
SequenceSettingsSettings for event sequences (single timestamp column).
- class tanat.sequence.type.IntervalEntity(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 interval row (start/end timestamps).
Unlike
StateEntity, intervals are not required to be contiguous: gaps between intervals are allowed, and two intervals may overlap in time.
- class tanat.sequence.type.IntervalSequence(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 interval sequence.
Unlike state sequences, intervals are not required to be contiguous: gaps between intervals are allowed, and two intervals may overlap in time.
- SETTINGS_CLASS[source]#
alias of
IntervalSequenceSettings
- __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 an interval 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 interval start column.
end_column – User-facing name for the interval 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.IntervalSequencePool(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 interval sequences.
Unlike state sequences, intervals are not required to be contiguous: gaps between intervals are allowed, and two intervals may overlap in time.
- SETTINGS_CLASS[source]#
alias of
IntervalSequenceSettings
- __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 an interval 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 interval start column.
end_column – User-facing name for the interval 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 interval 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() IntervalSequencePool[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).
- as_state() NoReturn[source]#
Not supported: interval → state conversion is ambiguous.
Intervals may overlap or contain gaps; neither property can be resolved into contiguous non-overlapping states without domain-specific merge / fill logic. Apply a manual Polars transformation instead.
- Raises:
NotImplementedError – Always.
- classmethod builder(*, sort_anchor: Literal['start', 'end', 'middle'] = 'start') IntervalSequenceStoreBuilder[source]#
Return a fluent builder for constructing an interval sequence store.
- Parameters:
sort_anchor – Intra-sequence sort column -
"start"(default),"end"for right-censored datasets, or"middle"to sort by the interval midpoint(T_START + T_END) / 2.
- class tanat.sequence.type.IntervalSequenceSettings(*, id_column: str, entity_features: list[str], static_features: list[str] = <factory>, start_column: str, end_column: str)[source]#
Bases:
SequenceSettingsSettings for interval sequences (start + end timestamp columns).
Unlike state sequences, intervals are not required to be contiguous: gaps between intervals are allowed, and two intervals may overlap in time.
- get_time_columns() list[str][source]#
Returns time index columns for Interval sequences [start, end].
- class tanat.sequence.type.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.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.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.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.