Source#

class deeptrack.sources.base.Source(**kwargs)#

Bases: object

A class that represents one or more sources of data.

This class is used to represent one or more sources of data. When accessed, it returns a deeptrack object that can be passed as properties to features.

The feature can then be called with an item from the source to get the value of the feature for that item.

Example#

>>> import deeptrack as dt
>>> from deeptrack.sources import Source
>>> source = Source(a=[1, 2], b=[3, 4])
>>> feature_a = dt.Value(source.a)
>>> feature_b = dt.Value(source.b)
>>> sum_feature = feature_a + feature_b
>>> sum_feature(source[0]) # returns 4
>>> sum_feature(source[1]) # returns 6

Parameters#

kwargs: dict

A dictionary of lists or arrays. The keys of the dictionary are the names of the sources, and the values are the sources themselves.

Methods Summary

constants(**kwargs)

Return a new source where the given values are constant.

filter(predicate)

Return a new source with only the items that satisfy the predicate.

on_activate(callback)

product(**kwargs)

Return the product of the source with the given sources.

set_index(index)

validate_all_same_length(kwargs)

Methods Documentation

constants(**kwargs) Product#

Return a new source where the given values are constant.

Example#

from deeptrack.sources import Source

>>> source = Source(a=[1, 2], b=[3, 4])
>>> new_source = source.constants(c=5)
>>> new_source
Equivalent to:
>>> Source(c=[5, 5], a=[1, 2], b=[3, 4]).

Parameters#

kwargs: dict

A dictionary of values. The keys of the dictionary are the names of the sources, and the values are the values themselves.

filter(predicate: Callable[[...], bool]) Subset#

Return a new source with only the items that satisfy the predicate.

Example#

>>> from deeptrack.sources import Source
>>> source = Source(a=[1, 2], b=[3, 4])
>>> new_source = source.filter(lambda a, b: a > 1)
>>> new_source
Equivalent to:
>>> Source(a=[2], b=[4]).
on_activate(callback: Callable[[Any], None]) None#
product(**kwargs) Product#

Return the product of the source with the given sources.

Returns a source that is the product of th source with the given sources.

Example#

>>> from deeptrack.sources import Source
>>> source = Source(a=[1, 2], b=[3, 4])
>>> new_source = source.product(c=[5, 6])
>>> new_source 
Source(c=[5, 6, 5, 6],
       a=[1, 1, 2, 2],
       b=[3, 3, 4, 4]
)

Parameters#

kwargs: dict

A dictionary of lists or arrays. The keys of the dictionary are the names of the sources, and the values are the sources themselves.

set_index(index: int) Source#
validate_all_same_length(kwargs: Dict[str, List[Any]]) None#