8000 Sequences restructuring by Pwhsky · Pull Request #331 · DeepTrackAI/DeepTrack2 · GitHub
[go: up one dir, main page]

Skip to content

Sequences restructuring #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added dependency support for the set methods.
  • Loading branch information
Pwhsky authored May 14, 2025
commit 929baf8c2ba2ff41e9b6baa60149a824d0d326fc
51 changes: 40 additions & 11 deletions deeptrack/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
import numpy as np

from .utils import get_kwarg_names
from .backend.core import DeepTrackNode
from deeptrack.backend.core import DeepTrackNode


class Property(DeepTrackNode):
Expand Down Expand Up @@ -588,7 +588,7 @@ def __init__(

# 6) Define a default current function for steps >= 1.
if current_value is not None:
self.current = self.create_action(current_value,**kwargs)
self.current = self.create_action(current_value, **kwargs)
else:
self.current = lambda _ID=(): None

Expand Down Expand Up @@ -692,19 +692,48 @@ def set_sequence_length(
value: Any,
_ID: Tuple[int, ...] = ()
) -> None:
"""Sets the length of sequence to be resolved.
...

"""Sets the `sequence_length` attribute of a sequence to be resolved.

Supports dependencies if `value` is a `Property`.

Parameters
----------
value : Any
The value to store in `sequence_length`.
_ID : Tuple[int, ...], optional
A unique identifier that allows the property to keep separate
histories for different parallel evaluations.

"""
self.sequence_length = Property(value, _ID=_ID)

if isinstance(value, Property):
self.sequence_length = Property(lambda _ID: value(_ID))
self.sequence_length.add_dependency(value)
else:
self.sequence_length = Property(value, _ID=_ID)

def set_current_step(
self,
value:Any,
_ID: Tuple[int, ...] = ()
self,
value: Any,
_ID: Tuple[int, ...] = ()
) -> None:
"""Sets the current index of the sequence.
"""Sets the `current_index` attribute of a sequence to be resolved.

Supports dependencies if `value` is a `Property`.

Parameters
----------
value : Any
The value to store in `current_step`.

_ID : Tuple[int, ...], optional
A unique identifier that allows the property to keep separate
histories for different parallel evaluations.

"""
self.sequence_step = Property(value, _ID=_ID)

if isinstance(value, Property): # For dependencies.
self.sequence_step = Property(lambda _ID: value(_ID))
self.sequence_step.add_dependency(value)
else:
self.sequence_step = Property(value, _ID=_ID)
0