4343>>> import deeptrack as dt
4444
4545Create and use a constant property:
46+
4647>>> const_prop = dt.Property(42)
4748>>> const_prop()
484942
4950
5051Define a dynamic property dependent on another:
52+
5153>>> const_prop = dt.Property(5)
5254>>> dynamic_prop = dt.Property(lambda x: x * 2, x=const_prop)
5355>>> dynamic_prop()
545610
5557
5658Create a dictionary of properties:
59+
5760>>> import numpy as np
5861>>>
5962>>> prop_dict = dt.PropertyDict(
6366... )
6467>>> prop_dict["constant"]()
656842
69+
6670>>> prop_dict["dependent"]()
677152
72+
6873>>> prop_dict["random"]()
697452.35065943710633
7075
7176Handle sequential properties:
77+
7278>>> seq_prop = dt.SequentialProperty(
7379... sampling_rule=lambda: np.random.randint(10, 20),
7480... )
@@ -136,15 +142,15 @@ class Property(DeepTrackNode):
136142 sampling_rule: Any
137143 The rule for sampling values. Can be a constant, function, list,
138144 dictionary, iterator, tuple, NumPy array, PyTorch tensor, slice,
139- or DeepTrackNode.
145+ or ` DeepTrackNode` .
140146 **dependencies: Property
141147 Additional dependencies passed as named arguments. These dependencies
142148 can be used as inputs to functions or other dynamic components of the
143149 sampling rule.
144150
145151 Methods
146152 -------
147- create_action(sampling_rule: Any , **dependencies: Property ) -> Callable[..., Any]
153+ ` create_action(sampling_rule, **dependencies) -> Callable[..., Any]`
148154 Creates an action that defines how the property is evaluated. The
149155 behavior of the action depends on the type of `sampling_rule`.
150156
@@ -189,6 +195,8 @@ class Property(DeepTrackNode):
189195 >>> dynamic_prop.update() # Updates the value
190196 >>> dynamic_prop() # Returns different random value
191197 0.5862725216547282
198+ >>> dynamic_prop.new() # Returns different random value
199+ 0.36122033451938484
192200
193201 >>> const_prop = dt.Property(5)
194202 >>> dynamic_prop = dt.Property(lambda x: 2 * x, x=const_prop)
@@ -216,14 +224,11 @@ class Property(DeepTrackNode):
216224 >>> iter_prop = dt.Property(iter([1, 2, 3]))
217225 >>> iter_prop()
218226 1
219- >>> iter_prop.update()
220- >>> iter_prop()
227+ >>> iter_prop.new() # equivalent to iter_prop.update()()
221228 2
222- >>> iter_prop.update()
223- >>> iter_prop()
229+ >>> iter_prop.new()
224230 3
225- >>> iter_prop.update()
226- >>> iter_prop() # Last value repeats
231+ >>> iter_prop.new() # Last value repeats
227232 3
228233
229234 Lists and dictionaries can contain properties, functions, or constants:
@@ -252,7 +257,7 @@ class Property(DeepTrackNode):
252257 100
253258
254259 >>> node = dt.DeepTrackNode(lambda _ID=(): np.random.rand())
255- >>> node_prop = Property(node)
260+ >>> node_prop = dt. Property(node)
256261 >>> node_prop()
257262 0.5065650298607408
258263
@@ -362,7 +367,7 @@ def create_action(
362367 or tuple or np.ndarray or torch.Tensor or slice
363368 or DeepTrackNode or Any
364369 The rule to sample values for the property.
365- **dependencies: dict[str, Property]
370+ **dependencies: Property
366371 Dependencies to be used in the sampling rule.
367372
368373 Returns
@@ -479,14 +484,15 @@ class PropertyDict(DeepTrackNode, dict):
479484
480485 Methods
481486 -------
482- __getitem__(key: str ) -> Any
487+ ` __getitem__(key) -> Any`
483488 Retrieves a value from the dictionary using a key.
484489
485490 Examples
486491 --------
487492 >>> import deeptrack as dt
488493
489494 Initialize a `PropertyDict` with different types of properties:
495+
490496 >>> import numpy as np
491497 >>>
492498 >>> prop_dict = dt.PropertyDict(
@@ -496,10 +502,13 @@ class PropertyDict(DeepTrackNode, dict):
496502 ... )
497503
498504 Access the properties:
505+
499506 >>> prop_dict["constant"]()
500507 42
508+
501509 >>> prop_dict["dependent"]()
502510 52
511+
503512 >>> prop_dict["random"]()
504513 0.33112452108057056
505514
@@ -536,8 +545,10 @@ def __init__(
536545 try :
537546 # Create a Property instance for the key,
538547 # resolving dependencies.
539- dependencies [key ] = Property (value ,
540- ** {** dependencies , ** kwargs })
548+ dependencies [key ] = Property (
549+ value ,
550+ ** {** dependencies , ** kwargs },
551+ )
541552 # Remove the key from the input dictionary once resolved.
542553 kwargs .pop (key )
543554 except AttributeError :
0 commit comments