incline.TimeAxis

class incline.TimeAxis(x, delta, unit)[source]

Numeric time positions for a series.

Variables:
  • x (numpy._typing._array_like.NDArray[numpy.float64]) – Strictly increasing positions. Days from the start for a DatetimeIndex, otherwise the index values themselves.

  • delta (float) – Median spacing between consecutive positions. Derivatives are reported per unit of x, so this is the scale factor between “per observation” and “per unit time”.

  • unit (str) – 'days' when derived from datetimes, else 'index'.

Parameters:
  • x (NDArray[float64])

  • delta (float)

  • unit (str)

__init__(x, delta, unit)
Parameters:
  • x (NDArray[float64])

  • delta (float)

  • unit (str)

Return type:

None

Methods

__init__(x, delta, unit)

from_frame(df[, time_column])

Build an axis from a DataFrame, preferring an explicit time column.

from_index(index)

Build an axis from a pandas index.

key()

A hashable identity for this axis.

positional(n)

Build a unit-spaced axis of length n.

require_regular(method)

Warn when a grid-based method is used on irregular sampling.

Attributes

is_regular

Whether the sampling is uniform enough for grid-based methods.

n

Number of observations.

spacing_cv

Coefficient of variation of the spacing.

span

Distance from the first to the last observation.

x

delta

unit

x: NDArray[float64]
delta: float
unit: str
classmethod from_index(index)[source]

Build an axis from a pandas index.

Parameters:

index (pd.Index) – A DatetimeIndex or PeriodIndex (converted to days from the start) or any numeric index.

Returns:

The corresponding TimeAxis.

Raises:

ValueError – If the index carries no time information.

Return type:

Self

classmethod from_frame(df, time_column=None)[source]

Build an axis from a DataFrame, preferring an explicit time column.

Parameters:
  • df (pd.DataFrame) – The series being estimated.

  • time_column (str | None) – Numeric time column. When None the index is used.

Returns:

The corresponding TimeAxis.

Return type:

Self

classmethod positional(n)[source]

Build a unit-spaced axis of length n.

Parameters:

n (int) – Number of observations.

Returns:

A TimeAxis over 0, 1, ..., n-1.

Return type:

Self

property n: int

Number of observations.

key()[source]

A hashable identity for this axis.

Used to cache linear operators, which depend on the axis and the smoother’s settings but never on the observed values.

Return type:

tuple[str, int, bytes]

property span: float

Distance from the first to the last observation.

property spacing_cv: float

Coefficient of variation of the spacing. Zero for a uniform grid.

property is_regular: bool

Whether the sampling is uniform enough for grid-based methods.

require_regular(method)[source]

Warn when a grid-based method is used on irregular sampling.

Parameters:

method (str) – Name of the method, used in the warning message.

Return type:

None