properties

Tools to manage the properties of a feature

Classes

Property

The class Property, which represents the values of a property of a feature. A Property be: * A constant (initialization with, e.g., a number, a tuple) * A sequence of variables (initialization with, e.g., an iterator) * A random variable (initialization with, e.g., a function)

SequentialProperty

The class SequentialProperty, which extends Property to sample one value for each step in a sequence.

PropertyDict

The class PropertyDict, which is a dictionary with each element a Property. The class provides utility functions to update, sample, clear and retrieve properties.

Module classes

Property

class deeptrack.properties.Property(sampling_rule: any)

Represents a property of a feature

The class Property` wraps an input, which is treated internally as a sampling rule. This sampling rule is used to update the value of the property. The sampling rule can be, for example: * A constant (initialization with, e.g., a number, a tuple) * A sequence of variables (initialization with, e.g., a generator) * A discrete random variable (initialization with, e.g., a list, a dictionary) * A continuous random variable (initialization with, e.g., a function)

Parameters

sampling_rule (any) – Defines the sampling rule to update the value of the feature property. See method sample() for how different sampling rules are sampled.

sampling_rule

The sampling rule to update the value of the feature property.

Type

any

current_value

The current value obtained from the last call to the sampling rule.

Type

any

has_updated_since_last_resolve

Whether the property has been updated since the last resolve.

Type

bool

sample(sampling_rule, **kwargs)

Samples the sampling rule

Returns a sampled instance of the sampling_rule field. The logic behind the sampling depends on the type of sampling_rule. These are checked in the following order of priority:

  1. Any object with a callable sample() method has this

    method called and returned.

  2. If the rule is a dict, sample each value and combine the

    result into a new dict using the original keys.

  3. If the rule is a list, sample each element of the list and

    combine the result into a ne list.

  4. If the rule is an iterable, return the next output.

  5. If the rule is callable, call it with its accepted arguments.

    Example arguments can be the value of some other property.

  6. If none of the above apply, return the rule itself.

Parameters
  • sampling_rule (any) – The rule to sample values from.

  • **kwargs – Arguments that will be passed on to functions that accepts them.

Returns

A sampled instance of the sampling_rule.

Return type

any

update(**kwargs) → deeptrack.properties.Property

Updates the current value

The method update() sets the property current_value as the output of the method sample(). Will only update once per resolve.

Any object that implements the method update() will have it called.

Returns

Returns itself.

Return type

Property

PropertyDict

class deeptrack.properties.PropertyDict

Dictionary with Property elements

A dictionary of properties. It provides utility functions to update, sample, reset and retrieve properties.

Parameters

**kwargs (*args,) –

Arguments used to initialize a dict

current_value_dict(is_resolving=False, **kwargs) → dict

Retrieves the current value of all properties as a dictionary

Returns

A dictionary with the current value of all properties

Return type

dict

sample(**kwargs) → dict

Samples all properties

Returns

A dictionary with each key-value pair the result of a sample() call on the property with the same key.

Return type

dict

update(**kwargs) → deeptrack.properties.PropertyDict

Updates all properties

Calls the method update() on each property in the dictionary.

Returns

Returns itself

Return type

Properties

SequentialProperty

class deeptrack.properties.SequentialProperty(sampling_rule, initializer=None)

Property that has multiple sequential values

Extends standard Property to resolve one value for each step in a sequence of images. This is often used when creating movies.

Parameters
  • initializer (any) – Sampling rule for the first step of the sequence.

  • sampling_rule (any) – Sampling rule for each step after the first.

initializer

Sampling rule for the first step of the sequence.

Type

any

sampling_rule

Sampling rule for each step after the first.

Type

any

has_updated_since_last_resolve

Whether the property has been updated since the last resolve.

Type

bool

update(sequence_length=0, **kwargs)

Updates current_value

For each step in the sequence, sample self.sampling_rule. self.initializer is used for the first step. These rules should output one value per step. Sampling rules that are functions can optionally accept the following keyword arguments:

  • sequence_step : the current position in the sequence.

  • sequence_length : the length of the sequence.

  • previous_value : the value of the property at the previous step in the sequence.

  • previous_values : the value of the property at all previous steps in the sequence.

Parameters

sequence_length (int, optional) – length of the sequence

Returns

returns self

Return type

self