@@ -988,12 +988,14 @@ class DeepTrackNode:
988988 DeepTrackNode(name='parent', len=0, action=<lambda>)
989989
990990 Print the dependency tree:
991+
991992 >>> grandchild.print_dependencies_tree()
992993 - DeepTrackNode 'grandchild' at 0x334201ea0
993994 - DeepTrackNode 'child' at 0x334201cf0
994995 - DeepTrackNode 'parent' at 0x334202650
995996
996997 Store and retrieve data for specific _IDs:
998+
997999 >>> parent.store(15, _ID=(0,))
9981000 >>> parent.store(20, _ID=(1,))
9991001 >>> parent.current_value((0,))
@@ -1002,6 +1004,7 @@ class DeepTrackNode:
10021004 20
10031005
10041006 Compute and retrieve the value for the child and grandchild node:
1007+
10051008 >>> child(_ID=(0,))
10061009 30
10071010 >>> child(_ID=(1,))
@@ -1012,6 +1015,7 @@ class DeepTrackNode:
10121015 120
10131016
10141017 Validation and invalidation:
1018+
10151019 >>> parent.is_valid((0,))
10161020 True
10171021 >>> child.is_valid((0,))
@@ -1036,6 +1040,7 @@ class DeepTrackNode:
10361040 False
10371041
10381042 Setting a value and automatic invalidation:
1043+
10391044 >>> parent.current_value((0,))
10401045 15
10411046 >>> grandchild((0,)) # Computes and stores the value in grandchild
@@ -1050,6 +1055,7 @@ class DeepTrackNode:
10501055 252
10511056
10521057 Resetting all data in the dependency tree (recomputation required):
1058+
10531059 >>> grandchild.update()
10541060 >>> grandchild()
10551061 60
@@ -1059,6 +1065,7 @@ class DeepTrackNode:
10591065 60
10601066
10611067 Operator overloading—arithmetic and comparison:
1068+
10621069 >>> node_a = DeepTrackNode(lambda: 5)
10631070 >>> node_b = DeepTrackNode(lambda: 3)
10641071
@@ -1091,26 +1098,31 @@ class DeepTrackNode:
10911098 True
10921099
10931100 Indexing into computed data:
1101+
10941102 >>> vector_node = DeepTrackNode(lambda: [10, 20, 30])
10951103 >>> first_element = vector_node[0]
10961104 >>> first_element()
10971105 10
10981106
10991107 Accessing a value before computing it raises an error:
1108+
11001109 >>> new_node = DeepTrackNode(lambda: 123)
11011110 >>> new_node.is_valid((42,))
11021111 False
1112+
11031113 >>> new_node.current_value((42,))
11041114 KeyError: 'Attempting to index an empty dict.'
11051115
11061116 Working with nested _ID slicing:
1117+
11071118 >>> parent = DeepTrackNode(lambda: 5)
11081119 >>> child = DeepTrackNode(lambda _ID=None: parent(_ID[:1]) + _ID[1])
11091120 >>> parent.add_child(child)
11101121 >>> child((0, 3)) # Equivalent to parent((0,)) + 3
11111122 8
11121123
11131124 Citations for a node and its dependencies:
1125+
11141126 >>> parent.get_citations() # Set of citation strings
11151127 {...}
11161128
0 commit comments