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.

DatetimeSplits

A list of bounds.

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.

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#

User schedule type.

alias of DatetimeIndex | Iterable[str | Timestamp | datetime | date | datetime64] | str | Timedelta | timedelta | timedelta64

Span#

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

alias of int | Literal[‘all’] | str | Timedelta | timedelta | timedelta64

ExpandLimits#

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

alias of bool | Literal[‘auto’] | str

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'] | str | Timedelta | timedelta | timedelta64#
after: int | Literal['all'] | str | Timedelta | timedelta | timedelta64#
step: int#
n_splits: int#
expand_limits: bool | Literal['auto'] | str#
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

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.