tanat.sequence.type.event package#

Submodules#

tanat.sequence.type.event.entity module#

Event entity implementation.

class tanat.sequence.type.event.entity.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: Entity

Entity representing one event row (single timestamp).

tanat.sequence.type.event.pool module#

Event sequence pool implementation.

tanat.sequence.type.event.pool.Duration = datetime.timedelta | int | float | str[source]#

Type alias for the duration argument in EventSequencePool.as_interval(). Can be a timedelta / numeric scalar (applied uniformly) or a str naming an entity feature column (per-row duration).

class tanat.sequence.type.event.pool.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: SequencePool

Pool 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 SequenceStore instance.

  • 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, or None.

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_end is 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 timedelta or 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".

  • destinationNone → 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_end is taken from the next event in the same sequence (shift(-1).over(_seq_id)).

Parameters:
  • end_value – Sentinel for _t_end of the last event per sequence. None leaves the last row with _t_end = null. A str names 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".

  • destinationNone → 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.

tanat.sequence.type.event.sequence module#

Event sequence implementation.

class tanat.sequence.type.event.sequence.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: Sequence

A 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 SequenceStore instance.

  • 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.

tanat.sequence.type.event.settings module#

Event sequence settings.

class tanat.sequence.type.event.settings.EventSequenceSettings(*, id_column: str, entity_features: list[str], static_features: list[str] = <factory>, time_column: str)[source]#

Bases: SequenceSettings

Settings for event sequences (single timestamp column).

__init__(*args: Any, **kwargs: Any) None[source]#
get_time_columns() list[str][source]#

Returns time index columns for Event sequences [time].

id_column: str[source]#
model_dump(*, mode='python', **dump_kwargs)[source]#

Dump settings to a dict via Pydantic serialization.

time_column: str[source]#

Module contents#

Event sequence subtypes.

class tanat.sequence.type.event.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: Entity

Entity representing one event row (single timestamp).

class tanat.sequence.type.event.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: Sequence

A 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 SequenceStore instance.

  • 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.event.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: SequencePool

Pool 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 SequenceStore instance.

  • 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, or None.

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_end is 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 timedelta or 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".

  • destinationNone → 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_end is taken from the next event in the same sequence (shift(-1).over(_seq_id)).

Parameters:
  • end_value – Sentinel for _t_end of the last event per sequence. None leaves the last row with _t_end = null. A str names 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".

  • destinationNone → 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.event.EventSequenceSettings(*, id_column: str, entity_features: list[str], static_features: list[str] = <factory>, time_column: str)[source]#

Bases: SequenceSettings

Settings for event sequences (single timestamp column).

__init__(*args: Any, **kwargs: Any) None[source]#
get_time_columns() list[str][source]#

Returns time index columns for Event sequences [time].

id_column: str[source]#
model_dump(*, mode='python', **dump_kwargs)[source]#

Dump settings to a dict via Pydantic serialization.

time_column: str[source]#