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.
- {invocation_tree-0.0.9/invocation_tree.egg-info → invocation_tree-0.0.10}/PKG-INFO +23 -11
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/README.md +23 -11
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression.py +2 -2
- invocation_tree-0.0.10/images/generator_pipeline.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_pipeline.py +9 -3
- invocation_tree-0.0.10/images/generator_pipeline1.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline10.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline11.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline12.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline13.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline14.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline15.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline16.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline17.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline18.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline19.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline2.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline20.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline21.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline22.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline23.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline24.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline25.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline26.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline27.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline3.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline4.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline5.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline6.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline7.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline8.png +0 -0
- invocation_tree-0.0.10/images/generator_pipeline9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/iterable.py +1 -1
- invocation_tree-0.0.10/images/permutations0.png +0 -0
- invocation_tree-0.0.10/images/permutations1.png +0 -0
- invocation_tree-0.0.10/images/permutations10.png +0 -0
- invocation_tree-0.0.10/images/permutations11.png +0 -0
- invocation_tree-0.0.10/images/permutations12.png +0 -0
- invocation_tree-0.0.10/images/permutations13.png +0 -0
- invocation_tree-0.0.10/images/permutations2.png +0 -0
- invocation_tree-0.0.10/images/permutations3.png +0 -0
- invocation_tree-0.0.10/images/permutations4.png +0 -0
- invocation_tree-0.0.10/images/permutations5.png +0 -0
- invocation_tree-0.0.10/images/permutations6.png +0 -0
- invocation_tree-0.0.10/images/permutations7.png +0 -0
- invocation_tree-0.0.10/images/permutations8.png +0 -0
- invocation_tree-0.0.10/images/permutations9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree/__init__.py +1 -1
- {invocation_tree-0.0.9 → invocation_tree-0.0.10/invocation_tree.egg-info}/PKG-INFO +23 -11
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/SOURCES.txt +3 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/setup.py +1 -1
- invocation_tree-0.0.9/images/generator_pipeline.gif +0 -0
- invocation_tree-0.0.9/images/generator_pipeline1.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline10.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline11.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline12.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline13.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline14.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline15.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline16.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline17.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline18.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline19.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline2.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline20.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline21.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline22.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline23.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline24.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline25.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline3.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline4.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline5.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline6.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline7.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline8.png +0 -0
- invocation_tree-0.0.9/images/generator_pipeline9.png +0 -0
- invocation_tree-0.0.9/images/permutations1.png +0 -0
- invocation_tree-0.0.9/images/permutations10.png +0 -0
- invocation_tree-0.0.9/images/permutations11.png +0 -0
- invocation_tree-0.0.9/images/permutations12.png +0 -0
- invocation_tree-0.0.9/images/permutations13.png +0 -0
- invocation_tree-0.0.9/images/permutations2.png +0 -0
- invocation_tree-0.0.9/images/permutations3.png +0 -0
- invocation_tree-0.0.9/images/permutations4.png +0 -0
- invocation_tree-0.0.9/images/permutations5.png +0 -0
- invocation_tree-0.0.9/images/permutations6.png +0 -0
- invocation_tree-0.0.9/images/permutations7.png +0 -0
- invocation_tree-0.0.9/images/permutations8.png +0 -0
- invocation_tree-0.0.9/images/permutations9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/LICENSE.txt +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/MANIFEST.in +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/#generator_function.py# +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute1.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute2.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute3.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute4.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute5.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute6.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute7.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute8.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/compute9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/create_gif.sh +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/create_images.sh +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/create_images.sh~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial1.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial2.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial3.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial4.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial5.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial6.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/factorial7.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression1.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression2.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression3.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression4.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression5.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression6.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression7.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression8.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_expression9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function1.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function2.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function3.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function4.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function5.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function6.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function7.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function8.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_function9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/generator_pipeline.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/invocation_tree.pdf +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/invocation_tree0.pdf +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/iterable.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_list.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_list.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range1.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range10.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range11.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range12.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range13.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range14.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range15.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range2.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range3.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range4.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range5.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range6.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range7.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range8.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/my_range9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/out.txt +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/permutations22.png~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/student.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students.gif +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students.py~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students1.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students10.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students11.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students12.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students13.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students14.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students15.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students2.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students3.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students4.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students5.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students6.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students7.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students8.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/students9.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/test.py +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/tree.gv~ +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/tree.pdf +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/images/vscode.png +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/install.txt +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/dependency_links.txt +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/requires.txt +0 -0
- {invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/top_level.txt +0 -0
- {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.
|
|
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
|

|
|
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
|
|
187
|
+
print(result) # all permutations of going Left or Right of length 2
|
|
185
188
|
```
|
|
186
189
|

|
|
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
|
|
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
|
|
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'
|
|
452
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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
|

|
|
@@ -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
|
|
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'
|
|
483
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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
|

|
|
@@ -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
|
|
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
|

|
|
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
|
|
168
|
+
print(result) # all permutations of going Left or Right of length 2
|
|
166
169
|
```
|
|
167
170
|

|
|
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
|
|
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
|
|
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'
|
|
433
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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
|

|
|
@@ -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
|
|
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'
|
|
464
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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
|

|
|
@@ -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
|
|
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'
|
|
10
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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) )
|
|
Binary file
|
|
@@ -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
|
|
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'
|
|
21
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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) )
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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: '
|
|
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))
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: invocation_tree
|
|
3
|
-
Version: 0.0.
|
|
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
|

|
|
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
|
|
187
|
+
print(result) # all permutations of going Left or Right of length 2
|
|
185
188
|
```
|
|
186
189
|

|
|
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
|
|
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
|
|
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'
|
|
452
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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
|

|
|
@@ -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
|
|
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'
|
|
483
|
-
tree.to_string[type(iter(range(0)))] = lambda x: '
|
|
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
|

|
|
@@ -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
|
|
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.
|
|
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',
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invocation_tree-0.0.9 → invocation_tree-0.0.10}/invocation_tree.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|