Ceil#
- class deeptrack.elementwise.Ceil(feature: Feature | None = None, **kwargs: Any)#
Bases:
ElementwiseFeatureApply the ceiling function elementwise.
This feature applies xp.ceil to each element in a NumPy array or a PyTorch tensor. It supports both direct input and pipeline composition.
The ceiling function returns the smallest integer greater than or equal to each element of the input.
Parameters#
- feature: Feature | None, optional
The input feature to which the ceil function will be applied. If None, the function is applied directly to the input array or tensor.
Examples#
>>> import deeptrack as dt >>> from deeptrack.elementwise import Ceil
Use with NumPy directly:
>>> import numpy as np >>> >>> result = Ceil()(np.array([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> result array([-1., -0., 0., 1., 2.])
Use with PyTorch directly:
>>> import torch >>> >>> result = Ceil()(torch.tensor([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> result tensor([-1., -0., 0., 1., 2.])
Use in a pipeline with a NumPy value:
>>> value = dt.Value(value=np.array([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> pipeline = value >> Ceil() >>> result = pipeline() >>> result array([-1., -0., 0., 1., 2.])
Use in a pipeline with a PyTorch value:
>>> value = dt.Value(value=torch.tensor([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> pipeline = value >> Ceil() >>> result = pipeline() >>> result tensor([-1., -0., 0., 1., 2.])
These are equivalent to:
>>> pipeline = Ceil(value)