Equals#

class deeptrack.features.Equals(value: float | Callable[[...], float] = 0, **kwargs: dict[str, Any])#

Bases: ArithmeticOperationFeature

Determine whether input is equal to a given value.

This feature performs element-wise comparison (==) between the input and a specified value.

Parameters#

value: PropertyLike[int or float], optional

The value to compare (==) with the input. Defaults to 0.

**kwargs: Any

Additional keyword arguments passed to the parent constructor.

Notes#

  • Unlike other arithmetic operators, Equals does not define __eq__ (==) and __req__ (==) in DeepTrackNode and Feature, as this would affect Python’s built-in identity comparison.

  • This means that the standard == operator is overloaded only for expressions involving Feature instances but not for comparisons involving regular Python objects.

  • Always use >> to apply Equals correctly in a feature chain.

Examples#

>>> import deeptrack as dt

Start by creating a pipeline using Equals: >>> pipeline = dt.Value([1, 2, 3]) >> dt.Equals(value=2) >>> pipeline.resolve() [False True False]

This is the only correct way to apply Equals in a feature pipeline.

### Incorrect Approaches Using == directly on a Feature instance does not work because Feature does not override __eq__: >>> pipeline = dt.Value([1, 2, 3]) == 2 # Incorrect >>> pipeline.resolve() AttributeError: ‘bool’ object has no attribute ‘resolve’

Similarly, directly calling Equals on an input feature immediately evaluates the comparison, returning a boolean instead of a Feature: >>> pipeline = dt.Equals(value=2)(dt.Value([1, 2, 3])) # Incorrect >>> pipeline.resolve() AttributeError: ‘bool’ object has no attribute ‘resolve’