invocation-tree 0.0.9__tar.gz → 0.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. {invocation_tree-0.0.9/invocation_tree.egg-info → invocation_tree-0.0.10}/PKG-INFO +23 -11
  2. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/README.md +23 -11
  3. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression.py +2 -2
  4. invocation_tree-0.0.10/images/generator_pipeline.gif +0 -0
  5. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_pipeline.py +9 -3
  6. invocation_tree-0.0.10/images/generator_pipeline1.png +0 -0
  7. invocation_tree-0.0.10/images/generator_pipeline10.png +0 -0
  8. invocation_tree-0.0.10/images/generator_pipeline11.png +0 -0
  9. invocation_tree-0.0.10/images/generator_pipeline12.png +0 -0
  10. invocation_tree-0.0.10/images/generator_pipeline13.png +0 -0
  11. invocation_tree-0.0.10/images/generator_pipeline14.png +0 -0
  12. invocation_tree-0.0.10/images/generator_pipeline15.png +0 -0
  13. invocation_tree-0.0.10/images/generator_pipeline16.png +0 -0
  14. invocation_tree-0.0.10/images/generator_pipeline17.png +0 -0
  15. invocation_tree-0.0.10/images/generator_pipeline18.png +0 -0
  16. invocation_tree-0.0.10/images/generator_pipeline19.png +0 -0
  17. invocation_tree-0.0.10/images/generator_pipeline2.png +0 -0
  18. invocation_tree-0.0.10/images/generator_pipeline20.png +0 -0
  19. invocation_tree-0.0.10/images/generator_pipeline21.png +0 -0
  20. invocation_tree-0.0.10/images/generator_pipeline22.png +0 -0
  21. invocation_tree-0.0.10/images/generator_pipeline23.png +0 -0
  22. invocation_tree-0.0.10/images/generator_pipeline24.png +0 -0
  23. invocation_tree-0.0.10/images/generator_pipeline25.png +0 -0
  24. invocation_tree-0.0.10/images/generator_pipeline26.png +0 -0
  25. invocation_tree-0.0.10/images/generator_pipeline27.png +0 -0
  26. invocation_tree-0.0.10/images/generator_pipeline3.png +0 -0
  27. invocation_tree-0.0.10/images/generator_pipeline4.png +0 -0
  28. invocation_tree-0.0.10/images/generator_pipeline5.png +0 -0
  29. invocation_tree-0.0.10/images/generator_pipeline6.png +0 -0
  30. invocation_tree-0.0.10/images/generator_pipeline7.png +0 -0
  31. invocation_tree-0.0.10/images/generator_pipeline8.png +0 -0
  32. invocation_tree-0.0.10/images/generator_pipeline9.png +0 -0
  33. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/iterable.py +1 -1
  34. invocation_tree-0.0.10/images/permutations0.png +0 -0
  35. invocation_tree-0.0.10/images/permutations1.png +0 -0
  36. invocation_tree-0.0.10/images/permutations10.png +0 -0
  37. invocation_tree-0.0.10/images/permutations11.png +0 -0
  38. invocation_tree-0.0.10/images/permutations12.png +0 -0
  39. invocation_tree-0.0.10/images/permutations13.png +0 -0
  40. invocation_tree-0.0.10/images/permutations2.png +0 -0
  41. invocation_tree-0.0.10/images/permutations3.png +0 -0
  42. invocation_tree-0.0.10/images/permutations4.png +0 -0
  43. invocation_tree-0.0.10/images/permutations5.png +0 -0
  44. invocation_tree-0.0.10/images/permutations6.png +0 -0
  45. invocation_tree-0.0.10/images/permutations7.png +0 -0
  46. invocation_tree-0.0.10/images/permutations8.png +0 -0
  47. invocation_tree-0.0.10/images/permutations9.png +0 -0
  48. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree/__init__.py +1 -1
  49. {invocation_tree-0.0.9 → invocation_tree-0.0.10/invocation_tree.egg-info}/PKG-INFO +23 -11
  50. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/SOURCES.txt +3 -0
  51. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/setup.py +1 -1
  52. invocation_tree-0.0.9/images/generator_pipeline.gif +0 -0
  53. invocation_tree-0.0.9/images/generator_pipeline1.png +0 -0
  54. invocation_tree-0.0.9/images/generator_pipeline10.png +0 -0
  55. invocation_tree-0.0.9/images/generator_pipeline11.png +0 -0
  56. invocation_tree-0.0.9/images/generator_pipeline12.png +0 -0
  57. invocation_tree-0.0.9/images/generator_pipeline13.png +0 -0
  58. invocation_tree-0.0.9/images/generator_pipeline14.png +0 -0
  59. invocation_tree-0.0.9/images/generator_pipeline15.png +0 -0
  60. invocation_tree-0.0.9/images/generator_pipeline16.png +0 -0
  61. invocation_tree-0.0.9/images/generator_pipeline17.png +0 -0
  62. invocation_tree-0.0.9/images/generator_pipeline18.png +0 -0
  63. invocation_tree-0.0.9/images/generator_pipeline19.png +0 -0
  64. invocation_tree-0.0.9/images/generator_pipeline2.png +0 -0
  65. invocation_tree-0.0.9/images/generator_pipeline20.png +0 -0
  66. invocation_tree-0.0.9/images/generator_pipeline21.png +0 -0
  67. invocation_tree-0.0.9/images/generator_pipeline22.png +0 -0
  68. invocation_tree-0.0.9/images/generator_pipeline23.png +0 -0
  69. invocation_tree-0.0.9/images/generator_pipeline24.png +0 -0
  70. invocation_tree-0.0.9/images/generator_pipeline25.png +0 -0
  71. invocation_tree-0.0.9/images/generator_pipeline3.png +0 -0
  72. invocation_tree-0.0.9/images/generator_pipeline4.png +0 -0
  73. invocation_tree-0.0.9/images/generator_pipeline5.png +0 -0
  74. invocation_tree-0.0.9/images/generator_pipeline6.png +0 -0
  75. invocation_tree-0.0.9/images/generator_pipeline7.png +0 -0
  76. invocation_tree-0.0.9/images/generator_pipeline8.png +0 -0
  77. invocation_tree-0.0.9/images/generator_pipeline9.png +0 -0
  78. invocation_tree-0.0.9/images/permutations1.png +0 -0
  79. invocation_tree-0.0.9/images/permutations10.png +0 -0
  80. invocation_tree-0.0.9/images/permutations11.png +0 -0
  81. invocation_tree-0.0.9/images/permutations12.png +0 -0
  82. invocation_tree-0.0.9/images/permutations13.png +0 -0
  83. invocation_tree-0.0.9/images/permutations2.png +0 -0
  84. invocation_tree-0.0.9/images/permutations3.png +0 -0
  85. invocation_tree-0.0.9/images/permutations4.png +0 -0
  86. invocation_tree-0.0.9/images/permutations5.png +0 -0
  87. invocation_tree-0.0.9/images/permutations6.png +0 -0
  88. invocation_tree-0.0.9/images/permutations7.png +0 -0
  89. invocation_tree-0.0.9/images/permutations8.png +0 -0
  90. invocation_tree-0.0.9/images/permutations9.png +0 -0
  91. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/LICENSE.txt +0 -0
  92. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/MANIFEST.in +0 -0
  93. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/#generator_function.py# +0 -0
  94. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute.gif +0 -0
  95. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute.py +0 -0
  96. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute.py~ +0 -0
  97. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute1.png +0 -0
  98. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute2.png +0 -0
  99. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute3.png +0 -0
  100. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute4.png +0 -0
  101. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute5.png +0 -0
  102. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute6.png +0 -0
  103. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute7.png +0 -0
  104. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute8.png +0 -0
  105. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute9.png +0 -0
  106. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/create_gif.sh +0 -0
  107. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/create_images.sh +0 -0
  108. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/create_images.sh~ +0 -0
  109. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial.gif +0 -0
  110. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial.py +0 -0
  111. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial.py~ +0 -0
  112. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial1.png +0 -0
  113. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial2.png +0 -0
  114. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial3.png +0 -0
  115. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial4.png +0 -0
  116. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial5.png +0 -0
  117. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial6.png +0 -0
  118. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial7.png +0 -0
  119. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression.gif +0 -0
  120. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression.py~ +0 -0
  121. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression1.png +0 -0
  122. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression2.png +0 -0
  123. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression3.png +0 -0
  124. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression4.png +0 -0
  125. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression5.png +0 -0
  126. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression6.png +0 -0
  127. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression7.png +0 -0
  128. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression8.png +0 -0
  129. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression9.png +0 -0
  130. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function.gif +0 -0
  131. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function.py +0 -0
  132. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function1.png +0 -0
  133. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function2.png +0 -0
  134. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function3.png +0 -0
  135. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function4.png +0 -0
  136. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function5.png +0 -0
  137. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function6.png +0 -0
  138. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function7.png +0 -0
  139. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function8.png +0 -0
  140. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function9.png +0 -0
  141. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_pipeline.py~ +0 -0
  142. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/invocation_tree.pdf +0 -0
  143. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/invocation_tree0.pdf +0 -0
  144. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/iterable.py~ +0 -0
  145. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_list.py +0 -0
  146. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_list.py~ +0 -0
  147. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range.gif +0 -0
  148. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range.py +0 -0
  149. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range.py~ +0 -0
  150. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range1.png +0 -0
  151. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range10.png +0 -0
  152. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range11.png +0 -0
  153. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range12.png +0 -0
  154. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range13.png +0 -0
  155. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range14.png +0 -0
  156. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range15.png +0 -0
  157. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range2.png +0 -0
  158. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range3.png +0 -0
  159. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range4.png +0 -0
  160. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range5.png +0 -0
  161. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range6.png +0 -0
  162. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range7.png +0 -0
  163. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range8.png +0 -0
  164. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range9.png +0 -0
  165. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/out.txt +0 -0
  166. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations.gif +0 -0
  167. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations.py +0 -0
  168. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations.py~ +0 -0
  169. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations22.png~ +0 -0
  170. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/student.gif +0 -0
  171. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students.gif +0 -0
  172. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students.py +0 -0
  173. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students.py~ +0 -0
  174. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students1.png +0 -0
  175. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students10.png +0 -0
  176. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students11.png +0 -0
  177. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students12.png +0 -0
  178. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students13.png +0 -0
  179. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students14.png +0 -0
  180. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students15.png +0 -0
  181. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students2.png +0 -0
  182. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students3.png +0 -0
  183. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students4.png +0 -0
  184. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students5.png +0 -0
  185. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students6.png +0 -0
  186. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students7.png +0 -0
  187. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students8.png +0 -0
  188. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students9.png +0 -0
  189. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/test.py +0 -0
  190. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/tree.gv~ +0 -0
  191. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/tree.pdf +0 -0
  192. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/vscode.png +0 -0
  193. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/install.txt +0 -0
  194. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/dependency_links.txt +0 -0
  195. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/requires.txt +0 -0
  196. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/top_level.txt +0 -0
  197. {invocation_tree-0.0.9 → invocation_tree-0.0.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: invocation_tree
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: Generate an invocation tree of functions calls.
5
5
  Home-page: https://github.com/bterwijn/invocation_tree
6
6
  Author: Bas Terwijn
@@ -165,6 +165,9 @@ tree = invo_tree.blocking()
165
165
  print( tree(factorial, 4) ) # show invocation tree of calling factorial(4)
166
166
  ```
167
167
  ![factorial](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/factorial.gif)
168
+ ```
169
+ 24
170
+ ```
168
171
 
169
172
  This `permutations()` example shows the depth-first nature of recursive execution:
170
173
 
@@ -181,9 +184,12 @@ def permutations(elements, perm, n):
181
184
 
182
185
  tree = invo_tree.blocking()
183
186
  result = tree(permutations, ['L','R'], '', 2)
184
- print(result) # all permutations of going Left and Right of length 2
187
+ print(result) # all permutations of going Left or Right of length 2
185
188
  ```
186
189
  ![permutations](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/permutations.gif)
190
+ ```
191
+ ['LL', 'LR', 'RL', 'RR']
192
+ ```
187
193
 
188
194
  ## Hide Variables ##
189
195
  In an educational context it can be useful to hide certian variables to avoid unnecessary complexity. This can for example be done with:
@@ -386,7 +392,7 @@ def main():
386
392
  main()
387
393
  ```
388
394
 
389
- A generator is lazy, meaning that it will only produce its values if you request them via the Iterator Protocol. That means that if you print the iterable produced by a generator it will just print '<generator object ...>'. To print its values you can for example use `list()` that uses the Iterator Protocol to request its values and converts them to a `list`, but then you have used the generator so it no longer has values.
395
+ A generator is lazy, meaning that it will only produce its values if you request them via the Iterator Protocol. That means that if you print the generator it will just print '<generator object ...>'. To print its values you can for example use `list()` that uses the Iterator Protocol to request its values and converts them to a `list` that can be printed. But then you have used the generator so it no longer has values.
390
396
 
391
397
  ```python
392
398
  def my_generator():
@@ -400,7 +406,7 @@ def main():
400
406
  print( list(my_gen) ) # printing uses up the generator
401
407
  print( list(my_gen) ) # no more values available
402
408
  print( list(my_generator()) ) # new generator
403
-
409
+
404
410
  main()
405
411
  ```
406
412
  ```
@@ -410,7 +416,7 @@ main()
410
416
  [1, 2, 3]
411
417
  ```
412
418
 
413
- By using invocation_tree we can see how a the Iterator Protocol works on the generator.
419
+ By using invocation_tree we can see how the Iterator Protocol works on the generator.
414
420
 
415
421
  ```python
416
422
  import invocation_tree as invo_tree
@@ -448,8 +454,8 @@ def main():
448
454
 
449
455
  tree = invo_tree.blocking()
450
456
  import types
451
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
452
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
457
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
458
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
453
459
  print( tree(main) )
454
460
  ```
455
461
  ![generator_expression.gif](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/generator_expression.gif)
@@ -469,18 +475,24 @@ def subtract(pipeline):
469
475
  def multiply(pipeline):
470
476
  for a in pipeline:
471
477
  yield a * 6
478
+
479
+ def my_sum(pipeline):
480
+ total = 0
481
+ for i in pipeline:
482
+ total += i
483
+ return total # return not yield, so not lazy
472
484
 
473
485
  def main():
474
486
  pipeline = range(1,4)
475
487
  pipeline = subtract(pipeline)
476
488
  pipeline = (a + 9 for a in pipeline)
477
489
  pipeline = multiply(pipeline)
478
- return sum(pipeline)
490
+ return my_sum(pipeline)
479
491
 
480
492
  tree = invo_tree.blocking()
481
493
  import types
482
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
483
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
494
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
495
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
484
496
  print( tree(main) )
485
497
  ```
486
498
  ![generator_pipeline.gif](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/generator_pipeline.gif)
@@ -537,7 +549,7 @@ For convenience we provide these functions to set common configurations:
537
549
  - **invo_tree.debugger(filename)**, non-blocking for use in debugger tool (open <filename> manually)
538
550
  - **invo_tree.gif(filename)**, generates many output files on function call and return for gif creation
539
551
  - **invo_tree.gif_each_change(filename)**, generates many output files on each change of value for gif creation
540
- - **invo_tree.non_blocking(filename)**, non blocking on each function call and return
552
+ - **invo_tree.non_blocking(filename)**, non-blocking on each function call and return
541
553
 
542
554
  # Troubleshooting #
543
555
  - Adobe Acrobat Reader [doesn't refresh a PDF file](https://superuser.com/questions/337011/windows-pdf-viewer-that-auto-refreshes-pdf-when-compiling-with-pdflatex) when it changes on disk and blocks updates which results in an `Could not open 'somefile.pdf' for writing : Permission denied` error. One solution is to install a PDF reader that does refresh ([Evince](https://www.fosshub.com/Evince.html), [Okular](https://okular.kde.org/), [SumatraPDF](https://www.sumatrapdfreader.org/), ...) and set it as the default PDF reader. Another solution is to save the tree to a different [Graphviz Output Format](https://graphviz.org/docs/outputs/).
@@ -146,6 +146,9 @@ tree = invo_tree.blocking()
146
146
  print( tree(factorial, 4) ) # show invocation tree of calling factorial(4)
147
147
  ```
148
148
  ![factorial](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/factorial.gif)
149
+ ```
150
+ 24
151
+ ```
149
152
 
150
153
  This `permutations()` example shows the depth-first nature of recursive execution:
151
154
 
@@ -162,9 +165,12 @@ def permutations(elements, perm, n):
162
165
 
163
166
  tree = invo_tree.blocking()
164
167
  result = tree(permutations, ['L','R'], '', 2)
165
- print(result) # all permutations of going Left and Right of length 2
168
+ print(result) # all permutations of going Left or Right of length 2
166
169
  ```
167
170
  ![permutations](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/permutations.gif)
171
+ ```
172
+ ['LL', 'LR', 'RL', 'RR']
173
+ ```
168
174
 
169
175
  ## Hide Variables ##
170
176
  In an educational context it can be useful to hide certian variables to avoid unnecessary complexity. This can for example be done with:
@@ -367,7 +373,7 @@ def main():
367
373
  main()
368
374
  ```
369
375
 
370
- A generator is lazy, meaning that it will only produce its values if you request them via the Iterator Protocol. That means that if you print the iterable produced by a generator it will just print '<generator object ...>'. To print its values you can for example use `list()` that uses the Iterator Protocol to request its values and converts them to a `list`, but then you have used the generator so it no longer has values.
376
+ A generator is lazy, meaning that it will only produce its values if you request them via the Iterator Protocol. That means that if you print the generator it will just print '<generator object ...>'. To print its values you can for example use `list()` that uses the Iterator Protocol to request its values and converts them to a `list` that can be printed. But then you have used the generator so it no longer has values.
371
377
 
372
378
  ```python
373
379
  def my_generator():
@@ -381,7 +387,7 @@ def main():
381
387
  print( list(my_gen) ) # printing uses up the generator
382
388
  print( list(my_gen) ) # no more values available
383
389
  print( list(my_generator()) ) # new generator
384
-
390
+
385
391
  main()
386
392
  ```
387
393
  ```
@@ -391,7 +397,7 @@ main()
391
397
  [1, 2, 3]
392
398
  ```
393
399
 
394
- By using invocation_tree we can see how a the Iterator Protocol works on the generator.
400
+ By using invocation_tree we can see how the Iterator Protocol works on the generator.
395
401
 
396
402
  ```python
397
403
  import invocation_tree as invo_tree
@@ -429,8 +435,8 @@ def main():
429
435
 
430
436
  tree = invo_tree.blocking()
431
437
  import types
432
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
433
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
438
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
439
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
434
440
  print( tree(main) )
435
441
  ```
436
442
  ![generator_expression.gif](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/generator_expression.gif)
@@ -450,18 +456,24 @@ def subtract(pipeline):
450
456
  def multiply(pipeline):
451
457
  for a in pipeline:
452
458
  yield a * 6
459
+
460
+ def my_sum(pipeline):
461
+ total = 0
462
+ for i in pipeline:
463
+ total += i
464
+ return total # return not yield, so not lazy
453
465
 
454
466
  def main():
455
467
  pipeline = range(1,4)
456
468
  pipeline = subtract(pipeline)
457
469
  pipeline = (a + 9 for a in pipeline)
458
470
  pipeline = multiply(pipeline)
459
- return sum(pipeline)
471
+ return my_sum(pipeline)
460
472
 
461
473
  tree = invo_tree.blocking()
462
474
  import types
463
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
464
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
475
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
476
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
465
477
  print( tree(main) )
466
478
  ```
467
479
  ![generator_pipeline.gif](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/generator_pipeline.gif)
@@ -518,10 +530,10 @@ For convenience we provide these functions to set common configurations:
518
530
  - **invo_tree.debugger(filename)**, non-blocking for use in debugger tool (open <filename> manually)
519
531
  - **invo_tree.gif(filename)**, generates many output files on function call and return for gif creation
520
532
  - **invo_tree.gif_each_change(filename)**, generates many output files on each change of value for gif creation
521
- - **invo_tree.non_blocking(filename)**, non blocking on each function call and return
533
+ - **invo_tree.non_blocking(filename)**, non-blocking on each function call and return
522
534
 
523
535
  # Troubleshooting #
524
536
  - Adobe Acrobat Reader [doesn't refresh a PDF file](https://superuser.com/questions/337011/windows-pdf-viewer-that-auto-refreshes-pdf-when-compiling-with-pdflatex) when it changes on disk and blocks updates which results in an `Could not open 'somefile.pdf' for writing : Permission denied` error. One solution is to install a PDF reader that does refresh ([Evince](https://www.fosshub.com/Evince.html), [Okular](https://okular.kde.org/), [SumatraPDF](https://www.sumatrapdfreader.org/), ...) and set it as the default PDF reader. Another solution is to save the tree to a different [Graphviz Output Format](https://graphviz.org/docs/outputs/).
525
537
 
526
538
  ## Memory_Graph Package ##
527
- The [invocation_tree](https://pypi.org/project/invocation-tree/) package visualizes function calls at different moments in time. If instead you want a detailed visualization of your data at the current time, check out the [memory_graph](https://pypi.org/project/memory-graph/) package.
539
+ The [invocation_tree](https://pypi.org/project/invocation-tree/) package visualizes function calls at different moments in time. If instead you want a detailed visualization of your data at the current time, check out the [memory_graph](https://pypi.org/project/memory-graph/) package.
@@ -6,6 +6,6 @@ def main():
6
6
 
7
7
  tree = invo_tree.gif('generator_expression.png')
8
8
  import types
9
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
10
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
9
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
10
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
11
11
  print( tree(main) )
@@ -7,16 +7,22 @@ def subtract(pipeline):
7
7
  def multiply(pipeline):
8
8
  for a in pipeline:
9
9
  yield a * 6
10
+
11
+ def my_sum(pipeline):
12
+ total = 0
13
+ for i in pipeline:
14
+ total += i
15
+ return total
10
16
 
11
17
  def main():
12
18
  pipeline = range(1,4)
13
19
  pipeline = subtract(pipeline)
14
20
  pipeline = (a + 9 for a in pipeline)
15
21
  pipeline = multiply(pipeline)
16
- return sum(pipeline)
22
+ return my_sum(pipeline)
17
23
 
18
24
  tree = invo_tree.gif('generator_pipeline.png')
19
25
  import types
20
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
21
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
26
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
27
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
22
28
  print( tree(main) )
@@ -37,7 +37,7 @@ def main():
37
37
  print(i)
38
38
 
39
39
  tree = invo_tree.blocking() # gif('genexp.png')
40
- #tree.to_string[type(iter(range(0)))] = lambda ri: 'range_iterator' # short name for range_iterator
40
+ #tree.to_string[type(iter(range(0)))] = lambda ri: 'iterator' # short name for iterator
41
41
  #tree.to_string[types.GeneratorType] = lambda gen: 'generator' # short name for generators
42
42
  tree.cleanup = False
43
43
  print('sum:', tree(main))
@@ -7,7 +7,7 @@ import html
7
7
  import sys
8
8
  import difflib
9
9
 
10
- __version__ = "0.0.9"
10
+ __version__ = "0.0.10"
11
11
  __author__ = 'Bas Terwijn'
12
12
 
13
13
  def highlight_diff(str1, str2):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: invocation_tree
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: Generate an invocation tree of functions calls.
5
5
  Home-page: https://github.com/bterwijn/invocation_tree
6
6
  Author: Bas Terwijn
@@ -165,6 +165,9 @@ tree = invo_tree.blocking()
165
165
  print( tree(factorial, 4) ) # show invocation tree of calling factorial(4)
166
166
  ```
167
167
  ![factorial](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/factorial.gif)
168
+ ```
169
+ 24
170
+ ```
168
171
 
169
172
  This `permutations()` example shows the depth-first nature of recursive execution:
170
173
 
@@ -181,9 +184,12 @@ def permutations(elements, perm, n):
181
184
 
182
185
  tree = invo_tree.blocking()
183
186
  result = tree(permutations, ['L','R'], '', 2)
184
- print(result) # all permutations of going Left and Right of length 2
187
+ print(result) # all permutations of going Left or Right of length 2
185
188
  ```
186
189
  ![permutations](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/permutations.gif)
190
+ ```
191
+ ['LL', 'LR', 'RL', 'RR']
192
+ ```
187
193
 
188
194
  ## Hide Variables ##
189
195
  In an educational context it can be useful to hide certian variables to avoid unnecessary complexity. This can for example be done with:
@@ -386,7 +392,7 @@ def main():
386
392
  main()
387
393
  ```
388
394
 
389
- A generator is lazy, meaning that it will only produce its values if you request them via the Iterator Protocol. That means that if you print the iterable produced by a generator it will just print '<generator object ...>'. To print its values you can for example use `list()` that uses the Iterator Protocol to request its values and converts them to a `list`, but then you have used the generator so it no longer has values.
395
+ A generator is lazy, meaning that it will only produce its values if you request them via the Iterator Protocol. That means that if you print the generator it will just print '<generator object ...>'. To print its values you can for example use `list()` that uses the Iterator Protocol to request its values and converts them to a `list` that can be printed. But then you have used the generator so it no longer has values.
390
396
 
391
397
  ```python
392
398
  def my_generator():
@@ -400,7 +406,7 @@ def main():
400
406
  print( list(my_gen) ) # printing uses up the generator
401
407
  print( list(my_gen) ) # no more values available
402
408
  print( list(my_generator()) ) # new generator
403
-
409
+
404
410
  main()
405
411
  ```
406
412
  ```
@@ -410,7 +416,7 @@ main()
410
416
  [1, 2, 3]
411
417
  ```
412
418
 
413
- By using invocation_tree we can see how a the Iterator Protocol works on the generator.
419
+ By using invocation_tree we can see how the Iterator Protocol works on the generator.
414
420
 
415
421
  ```python
416
422
  import invocation_tree as invo_tree
@@ -448,8 +454,8 @@ def main():
448
454
 
449
455
  tree = invo_tree.blocking()
450
456
  import types
451
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
452
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
457
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
458
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
453
459
  print( tree(main) )
454
460
  ```
455
461
  ![generator_expression.gif](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/generator_expression.gif)
@@ -469,18 +475,24 @@ def subtract(pipeline):
469
475
  def multiply(pipeline):
470
476
  for a in pipeline:
471
477
  yield a * 6
478
+
479
+ def my_sum(pipeline):
480
+ total = 0
481
+ for i in pipeline:
482
+ total += i
483
+ return total # return not yield, so not lazy
472
484
 
473
485
  def main():
474
486
  pipeline = range(1,4)
475
487
  pipeline = subtract(pipeline)
476
488
  pipeline = (a + 9 for a in pipeline)
477
489
  pipeline = multiply(pipeline)
478
- return sum(pipeline)
490
+ return my_sum(pipeline)
479
491
 
480
492
  tree = invo_tree.blocking()
481
493
  import types
482
- tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
483
- tree.to_string[type(iter(range(0)))] = lambda x: 'range_iterator' # short name for range_iterator
494
+ tree.to_string[types.GeneratorType] = lambda x: 'generator' # short name for generators
495
+ tree.to_string[type(iter(range(0)))] = lambda x: 'iterator' # short name for iterator
484
496
  print( tree(main) )
485
497
  ```
486
498
  ![generator_pipeline.gif](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/generator_pipeline.gif)
@@ -537,7 +549,7 @@ For convenience we provide these functions to set common configurations:
537
549
  - **invo_tree.debugger(filename)**, non-blocking for use in debugger tool (open <filename> manually)
538
550
  - **invo_tree.gif(filename)**, generates many output files on function call and return for gif creation
539
551
  - **invo_tree.gif_each_change(filename)**, generates many output files on each change of value for gif creation
540
- - **invo_tree.non_blocking(filename)**, non blocking on each function call and return
552
+ - **invo_tree.non_blocking(filename)**, non-blocking on each function call and return
541
553
 
542
554
  # Troubleshooting #
543
555
  - Adobe Acrobat Reader [doesn't refresh a PDF file](https://superuser.com/questions/337011/windows-pdf-viewer-that-auto-refreshes-pdf-when-compiling-with-pdflatex) when it changes on disk and blocks updates which results in an `Could not open 'somefile.pdf' for writing : Permission denied` error. One solution is to install a PDF reader that does refresh ([Evince](https://www.fosshub.com/Evince.html), [Okular](https://okular.kde.org/), [SumatraPDF](https://www.sumatrapdfreader.org/), ...) and set it as the default PDF reader. Another solution is to save the tree to a different [Graphviz Output Format](https://graphviz.org/docs/outputs/).
@@ -73,6 +73,8 @@ images/generator_pipeline22.png
73
73
  images/generator_pipeline23.png
74
74
  images/generator_pipeline24.png
75
75
  images/generator_pipeline25.png
76
+ images/generator_pipeline26.png
77
+ images/generator_pipeline27.png
76
78
  images/generator_pipeline3.png
77
79
  images/generator_pipeline4.png
78
80
  images/generator_pipeline5.png
@@ -108,6 +110,7 @@ images/out.txt
108
110
  images/permutations.gif
109
111
  images/permutations.py
110
112
  images/permutations.py~
113
+ images/permutations0.png
111
114
  images/permutations1.png
112
115
  images/permutations10.png
113
116
  images/permutations11.png
@@ -11,7 +11,7 @@ long_description_from_readme = (this_directory / "README.md").read_text()
11
11
 
12
12
  setup(
13
13
  name = 'invocation_tree',
14
- version = '0.0.9',
14
+ version = '0.0.10',
15
15
  description = 'Generate an invocation tree of functions calls.',
16
16
  long_description = long_description_from_readme,
17
17
  long_description_content_type = 'text/markdown',