pyinterp.core.period.PeriodList

Contents

pyinterp.core.period.PeriodList#

class pyinterp.core.period.PeriodList(self, periods: list | None = None)#
class pyinterp.core.period.PeriodList(self, periods: object | None = None, within: bool = True)

Bases: object

A list of Period objects.

Overloaded function.

  1. __init__(self, periods: list | None = None) -> None

A PeriodList object representing a list of Periods.

Parameters:

periods – If None (or not provided), creates an empty PeriodList. Otherwise, a Python list of Period objects to initialize the PeriodList.

  1. __init__(self, periods: object | None = None, within: bool = True) -> None

A PeriodList object representing a list of Periods.

Parameters:
  • periods – If None (or not provided), creates an empty PeriodList. Otherwise, a Nx2 numpy.datetime64 array where each row defines a Period with [begin, end].

  • within – If True, end is inclusive; if False, end is exclusive.

Attributes

resolution

The resolution dtype of the periods in the list.

Public Methods

aggregate_duration(self)

Calculate the total duration covered by the periods in the list.

append(self, period)

Append a Period to the PeriodList.

belong_to_a_period(self, dates)

Test which dates fall within any of the managed periods.

cross_a_period(self, dates)

Identify dates that cross (enter or are within) any managed period.

duration(self)

Calculate the total duration covered by the periods in the list.

extend(self, periods)

filter_contained(self, period)

Filter periods that are fully contained within the given Period.

filter_min_duration(self, duration)

Filter periods with a minimum duration.

find_containing(self, date)

Find the Period containing the given date.

insert(self, index, period)

is_close(self, date, tolerance)

Check if the given date is within tolerance of any period in the list.

is_sorted_and_disjoint(self)

Check if the periods in the list are sorted and non-overlapping.

join_adjacent_periods(self, epsilon)

Join periods that are adjacent within a specified epsilon.

merge(self, other)

Merge another PeriodList into this PeriodList.

pop(self[, index])

sort(self)

Sort the periods in the list by their begin time.

Special Methods

__delitem__(-> None)

__getitem__(-> pyinterp.core.period.Period)

__getstate__(self)

Get the state for pickling.

__iter__(self)

__len__(self)

__new__(*args, **kwargs)

__repr__(self)

String representation of the PeriodList.

__setitem__(-> None)

__setstate__(self, state)

Set the state of the instance from pickling.