time_split.types#

Types related to splitting data.

Module Attributes

DatetimeTypes

Types that may be cast to pandas.Timestamp.

DatetimeIterable

Iterable that may be cast to pandas.DatetimeIndex.

TimedeltaTypes

Types that may be cast to pandas.Timedelta.

Schedule

User schedule type.

Span

User span type.

ExpandLimits

Limits flexibility spec for floor/ceil.

Filter

A callable (start, mid, end) -> bool used to filter folds.

DatetimeSplits

A list of bounds.

LogSplitProgressLoggerArg

A logger or string.

MetricsType

Metrics argument type.

GetMetrics

A callable (Timestamp) -> MetricsType.

FormatMetrics

A callable (end_message, metrics) -> str.

Classes

DatetimeIndexSplitterKwargs

Keyword arguments for DatetimeIndexSplitter.

DatetimeSplitBounds(start, mid, end)

A 3-tuple which denotes two adjacent datetime ranges.

DatetimeSplitCounts(data, future_data)

Relative importance of data and future_data.

LogSplitProgress()

The sequence-like return type of log_split_progress().

LogSplitProgressKwargs

Keyword arguments for by log_split_progress().

SplitProgressExtras

Named extras used for messages logged by log_split_progress().

DatetimeTypes: TypeAlias = str | pandas._libs.tslibs.timestamps.Timestamp | datetime.datetime | datetime.date | numpy.datetime64#

Types that may be cast to pandas.Timestamp.

DatetimeIterable#

Iterable that may be cast to pandas.DatetimeIndex.

alias of Iterable[str | Timestamp | datetime | date | datetime64]

TimedeltaTypes: TypeAlias = str | pandas._libs.tslibs.timedeltas.Timedelta | datetime.timedelta | numpy.timedelta64#

Types that may be cast to pandas.Timedelta.

Schedule: TypeAlias = pandas.core.indexes.datetimes.DatetimeIndex | collections.abc.Iterable[str | pandas._libs.tslibs.timestamps.Timestamp | datetime.datetime | datetime.date | numpy.datetime64] | str | pandas._libs.tslibs.timedeltas.Timedelta | datetime.timedelta | numpy.timedelta64#

User schedule type.

Span = int | typing.Literal['all', 'empty'] | str | pandas._libs.tslibs.timedeltas.Timedelta | datetime.timedelta | numpy.timedelta64#

User span type. Used to determine limits from the timestamps given by a Schedule.

ExpandLimits = bool | typing.Literal['auto'] | str#

Limits flexibility spec for floor/ceil. Pass False to disable.

Filter#

A callable (start, mid, end) -> bool used to filter folds.

alias of Callable[[Timestamp, Timestamp, Timestamp], bool]

class DatetimeSplitBounds(start: Timestamp, mid: Timestamp, end: Timestamp)[source]#

Bases: NamedTuple

A 3-tuple which denotes two adjacent datetime ranges.

start: Timestamp#

Left (inclusive) limit of the data range.

mid: Timestamp#

Schedule timestamp; simulated training_date.

Right (exclusive) limit of the data range, left (inclusive) limit of the future_data range.

When using integration functions, These are available as DatetimeSplit.data and DatetimeSplit.future_data, respectively.

end: Timestamp#

Right (exclusive) limit of the future_data range.

DatetimeSplits#

A list of bounds.

alias of list[DatetimeSplitBounds]

class DatetimeSplitCounts(data: int, future_data: int)[source]#

Bases: NamedTuple

Relative importance of data and future_data.

data: int#

Alias for field number 0

future_data: int#

Alias for field number 1

class DatetimeIndexSplitterKwargs[source]#

Bases: TypedDict

Keyword arguments for DatetimeIndexSplitter.

The DatetimeIndexSplitter is a backend implementation. In most cases, it should not be used directly. See time_split.split() or one of the related functions for user-facing APIs.

schedule: Required[DatetimeIndex | Iterable[str | Timestamp | datetime | date | datetime64] | str | Timedelta | timedelta | timedelta64]#
before: int | Literal['all', 'empty'] | str | Timedelta | timedelta | timedelta64#
after: int | Literal['all', 'empty'] | str | Timedelta | timedelta | timedelta64#
step: int#
n_splits: int#
expand_limits: bool | Literal['auto'] | str#
filter: Callable[[Timestamp, Timestamp, Timestamp], bool] | str | None#
LogSplitProgressLoggerArg = logging.Logger | logging.LoggerAdapter[typing.Any] | str#

A logger or string.

class MetricsType#

Metrics argument type.

alias of TypeVar(‘MetricsType’)

GetMetrics#

A callable (Timestamp) -> MetricsType.

alias of Callable[[Timestamp], MetricsType]

FormatMetrics#

A callable (end_message, metrics) -> str.

alias of Callable[[str, MetricsType], str]

class LogSplitProgressKwargs[source]#

Bases: TypedDict, Generic[MetricsType]

Keyword arguments for by log_split_progress().

logger: Logger | LoggerAdapter[Any] | str#
start_level: int#
end_level: int#
extra: dict[str, Any] | None#
get_metrics: Callable[[Timestamp], MetricsType]#
class SplitProgressExtras[source]#

Bases: TypedDict, Generic[MetricsType]

Named extras used for messages logged by log_split_progress().

n: int#

Current split number (starting at 1).

n_splits: int#

Total split count.

start: str#

An ISO-formatted timestamp (see DatetimeSplitBounds.start).

mid: str#

An ISO-formatted timestamp (see DatetimeSplitBounds.mid).

end: str#

An ISO-formatted timestamp (see DatetimeSplitBounds.end).

seconds: NotRequired[float]#

User time for the fold. Available only for the fold-end message.

metrics: NotRequired[MetricsType]#

Optional fold metrics. Typically appended to the fold-end message.

class LogSplitProgress[source]#

Bases: ABC, Sequence[DatetimeSplitBounds]

The sequence-like return type of log_split_progress().

A sequence [(start, mid, end), ...] which logs progress when iterating.

splits: Sequence[DatetimeSplitBounds]#

The underlying splits.

logger: Logger | LoggerAdapter#

Logger instance that emits messages.