temporian.types #
Types used throughout the API.
EventSetCollection
module-attribute
#
EventSetCollection = Union[
EventSet, List[EventSet], Dict[str, EventSet]
]
A collection of EventSets
.
This can be a single EventSet, a list of EventSets, or a dictionary mapping names to EventSets.
EventSetNodeCollection
module-attribute
#
EventSetNodeCollection = Union[
EventSetNode,
List[EventSetNode],
Set[EventSetNode],
Dict[str, EventSetNode],
]
A collection of EventSetNodes
.
This can be a single EventSetNode, a list or set of EventSetNodes, or a dictionary mapping names to EventSetNodes.
EventSetOrNode
module-attribute
#
EventSetOrNode = TypeVar(
"EventSetOrNode",
EventSet,
EventSetNode,
EventSetOperations,
)
Generic type for an EventSet
or
EventSetNode
.
Mainly used to define the input and output types of operators and Temporian functions.
A function typed as f(a: EventSetOrNode, ...) -> EventSetOrNode
indicates that
the function receives either EventSets or EventSetNodes as input, and returns
that same type as output. In other words, f(evset)
returns an EventSet, and
f(node)
returns an EventSetNode.
IndexKey
module-attribute
#
IndexKey = Union[Tuple[IndexKeyItem, ...], IndexKeyItem]
An index key is a tuple of values that identifies a single time sequence
inside an EventSet
.
If, for example, your EventSet is indexed by "name"
and "number"
, with the
values on those being ["Mark", "Sarah"]
and [1, 2, 3]
respectively, the
possible index keys would be ("Mark", 1)
, ("Mark", 2)
, ("Mark", 3)
,
("Sarah", 1)
, ("Sarah", 2)
, and ("Sarah", 3)
.
An index key can take the form of a single value (e.g. "Mark"
) if it is being
used with an EventSet with a single index. In this case, using "Mark"
is
equivalent to using ("Mark",)
.
IndexKeyItem
module-attribute
#
IndexKeyItem = Union[int, str, bytes]
One of the values inside an IndexKey.
IndexKeyList
module-attribute
#
IndexKeyList = Union[IndexKey, List[IndexKey]]
A list of IndexKeys
.
Auxiliary type to allow receiving a single IndexKey or a list of IndexKeys.
If receiving a single IndexKey, it is equivalent to receiving a list with a single IndexKey.
MapFunction
module-attribute
#
MapFunction = Union[
Callable[[Any], Scalar],
Callable[[Any, MapExtras], Scalar],
]
NodeToEventSetMapping
module-attribute
#
NodeToEventSetMapping = Union[
Dict[EventSetNode, EventSet], EventSet, List[EventSet]
]
A mapping of EventSetNodes
to
EventSets
.
If a dictionary, the mapping is defined by it.
If a single EventSet or a list of EventSets, each EventSet is mapped to their
own node using EventSet.node()
, i.e., [evset]
is equivalent to {evset.node() : evset}
.
WindowLength
module-attribute
#
WindowLength = Union[Duration, EventSetOrNode]
Window length of a moving window operator.
A window length can be either constant or variable.
A constant window length is specified with a
Duration. For example, window_length=5.0
or
window_length=tp.duration.days(4)
.
A variable window length is specified with an EventSet
containing a single float64 feature. This EventSet can have the same sampling as
the input EventSet or a different one, in which case the output will have the
same sampling as the window_length
EventSet. In both cases the feature value
on each timestamp will dictate the length of the window in that timestamp.
If an EventSet
, it should contain strictly positive values. If receiving 0,
negative values, or missing values, the operator will treat the window as empty.