Tan#

class deeptrack.elementwise.Tan(feature: Feature | None = None, **kwargs: Any)#

Bases: ElementwiseFeature

Apply the tangent function elementwise.

This feature applies xp.tan to each element in a NumPy array or a PyTorch tensor. It supports both direct input and pipeline composition.

Parameters#

feature: Feature | None, optional

The input feature to which the tangent 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 Tan

Use with NumPy directly:

>>> import numpy as np
>>>
>>> result = Tan()(np.array([0, np.pi / 4, np.pi / 2]))
>>> result
array([0.00000000e+00, 1.00000000e+00, 1.63312394e+16])

Use with PyTorch directly:

>>> import torch
>>>
>>> result = Tan()(torch.tensor([0, torch.pi / 4, torch.pi / 2]))
>>> result
tensor([ 0.0000e+00,  1.0000e+00, -2.2877e+07])

Use in a pipeline with a NumPy value:

>>> value = dt.Value(value=np.array([0, np.pi / 4, np.pi / 2]))
>>> pipeline = value >> Tan()
>>> result = pipeline()
>>> result
array([0.00000000e+00, 1.00000000e+00, 1.63312394e+16])

Use in a pipeline with a PyTorch value:

>>> value = dt.Value(value=torch.tensor([0, torch.pi / 4, torch.pi / 2]))
>>> pipeline = value >> Tan()
>>> result = pipeline()
>>> result
tensor([ 0.0000e+00,  1.0000e+00, -2.2877e+07])

These are equivalent to:

>>> pipeline = Tan(value)