TakeProperties#

class deeptrack.features.TakeProperties(feature: Feature, *names: str, **kwargs: Any)#

Bases: Feature

Extract all instances of a set of properties from a pipeline.

Only extracts the properties from dependencies that contain all given property names. The order of the properties is not guaranteed to be the same as the evaluation order.

If there is only a single property name, this will return a list of the property values.

Parameters#

feature: Feature

The feature from which to extract properties.

*names: str

The names of the properties to extract.

**kwargs: Any

Additional keyword arguments passed to the parent Feature class.

Attributes#

__distributed__: bool

Always False for TakeProperties, as it processes sequentially.

__list_merge_strategy__: int

Specifies how lists of properties are merged. Set to MERGE_STRATEGY_APPEND to append values to the result list.

Methods#

get(*_, names, _ID, **kwargs) -> list[Any] | tuple[list[Any], …]

Extract the specified properties from the feature pipeline. When evaluating the feature, single-element lists may be unwrapped to scalars by the Feature post-processing.

Examples#

>>> import deeptrack as dt
>>> class ExampleFeature(dt.Feature):
...     def __init__(self, my_property, **kwargs):
...         super().__init__(my_property=my_property, **kwargs)

Create an example feature with a property:

>>> feature = ExampleFeature(my_property=dt.Property(42))

Use TakeProperties to extract the property:

>>> take_my_property = dt.TakeProperties(feature, "my_property")
>>> output = take_my_property(None)
>>> output
42

Create a Gaussian feature:

>>> noise_feature = dt.Gaussian(mu=7, sigma=12)

Use TakeProperties to extract the property:

>>> take_properties = dt.TakeProperties(noise_feature, "mu", "sigma")
>>> output = take_properties(None)
>>> output
(7, 12)

Methods Summary

get(*_, names[, _ID])

Extract the specified properties from the feature pipeline.

Methods Documentation

get(*_: Any, names: tuple[str, ...], _ID: tuple[int, ...] = (), **kwargs: Any) list[Any] | tuple[list[Any], ...]#

Extract the specified properties from the feature pipeline.

This method retrieves the values of the specified properties from the feature’s dependency graph and returns them as lists of values.

Parameters#

*_: Any

The input data (unused in this method).

names: tuple[str, …]

The names of the properties to extract.

_ID: tuple[int, …], optional

A unique identifier for the current computation, ensuring that dependencies are correctly matched. It defaults to an empty tuple.

**kwargs: Any, optional

Additional keyword arguments (unused in this method).

Returns#

list[Any] or tuple[list[Any], …]

If a single property name is provided, a list of extracted values is returned. If multiple property names are provided, a tuple of lists is returned, one per property name. Note that when evaluating the feature (calling it), DeepTrack may unwrap single-element lists and return scalars.