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: >>> 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#
- kwargsdict
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)#
Return a new source where the given values are constant.
Example: >>> source = Source(a=[1, 2], b=[3, 4]) >>> new_source = source.constants(c=5) >>> new_source # returns Source(c=[5, 5], a=[1, 2], b=[3, 4])
Parameters#
- kwargsdict
A dictionary of values. The keys of the dictionary are the names of the sources, and the values are the values themselves.
- filter(predicate)#
Return a new source with only the items that satisfy the predicate.
Example: >>> source = Source(a=[1, 2], b=[3, 4]) >>> new_source = source.filter(lambda a, b: a > 1) >>> new_source # returns Source(a=[2], b=[4])
- on_activate(callback: callable)#
- product(**kwargs)#
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: >>> source = Source(a=[1, 2], b=[3, 4]) >>> new_source = source.product(c=[5, 6]) >>> new_source # returns Source(c=[5, 6, 5, 6],
a=[1, 1, 2, 2], b=[3, 3, 4, 4]
)
Parameters#
- kwargsdict
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)#
- validate_all_same_length(kwargs)#