|
81 | 81 | import numpy as np |
82 | 82 |
|
83 | 83 | from .utils import get_kwarg_names |
84 | | -from .backend.core import DeepTrackNode |
| 84 | +from deeptrack.backend.core import DeepTrackNode |
85 | 85 |
|
86 | 86 |
|
87 | 87 | class Property(DeepTrackNode): |
@@ -588,7 +588,7 @@ def __init__( |
588 | 588 |
|
589 | 589 | # 6) Define a default current function for steps >= 1. |
590 | 590 | if current_value is not None: |
591 | | - self.current = self.create_action(current_value,**kwargs) |
| 591 | + self.current = self.create_action(current_value, **kwargs) |
592 | 592 | else: |
593 | 593 | self.current = lambda _ID=(): None |
594 | 594 |
|
@@ -692,19 +692,48 @@ def set_sequence_length( |
692 | 692 | value: Any, |
693 | 693 | _ID: Tuple[int, ...] = () |
694 | 694 | ) -> None: |
695 | | - """Sets the length of sequence to be resolved. |
696 | | - ... |
697 | | - |
| 695 | + """Sets the `sequence_length` attribute of a sequence to be resolved. |
| 696 | +
|
| 697 | + Supports dependencies if `value` is a `Property`. |
| 698 | +
|
| 699 | + Parameters |
| 700 | + ---------- |
| 701 | + value : Any |
| 702 | + The value to store in `sequence_length`. |
| 703 | + _ID : Tuple[int, ...], optional |
| 704 | + A unique identifier that allows the property to keep separate |
| 705 | + histories for different parallel evaluations. |
| 706 | +
|
698 | 707 | """ |
699 | | - self.sequence_length = Property(value, _ID=_ID) |
700 | 708 |
|
| 709 | + if isinstance(value, Property): |
| 710 | + self.sequence_length = Property(lambda _ID: value(_ID)) |
| 711 | + self.sequence_length.add_dependency(value) |
| 712 | + else: |
| 713 | + self.sequence_length = Property(value, _ID=_ID) |
701 | 714 |
|
702 | 715 | def set_current_step( |
703 | | - self, |
704 | | - value:Any, |
705 | | - _ID: Tuple[int, ...] = () |
| 716 | + self, |
| 717 | + value: Any, |
| 718 | + _ID: Tuple[int, ...] = () |
706 | 719 | ) -> None: |
707 | | - """Sets the current index of the sequence. |
| 720 | + """Sets the `current_index` attribute of a sequence to be resolved. |
| 721 | +
|
| 722 | + Supports dependencies if `value` is a `Property`. |
| 723 | +
|
| 724 | + Parameters |
| 725 | + ---------- |
| 726 | + value : Any |
| 727 | + The value to store in `current_step`. |
| 728 | +
|
| 729 | + _ID : Tuple[int, ...], optional |
| 730 | + A unique identifier that allows the property to keep separate |
| 731 | + histories for different parallel evaluations. |
708 | 732 | |
709 | 733 | """ |
710 | | - self.sequence_step = Property(value, _ID=_ID) |
| 734 | + |
| 735 | + if isinstance(value, Property): # For dependencies. |
| 736 | + self.sequence_step = Property(lambda _ID: value(_ID)) |
| 737 | + self.sequence_step.add_dependency(value) |
| 738 | + else: |
| 739 | + self.sequence_step = Property(value, _ID=_ID) |
0 commit comments