invocation-tree 0.0.4__tar.gz → 0.0.6__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 (118) hide show
  1. {invocation_tree-0.0.4/invocation_tree.egg-info → invocation_tree-0.0.6}/PKG-INFO +25 -14
  2. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/README.md +24 -13
  3. invocation_tree-0.0.6/images/factorial0.png +0 -0
  4. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial1.png +0 -0
  5. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial2.png +0 -0
  6. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial3.png +0 -0
  7. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial4.png +0 -0
  8. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial5.png +0 -0
  9. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial6.png +0 -0
  10. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial7.png +0 -0
  11. invocation_tree-0.0.6/images/permutations0.png +0 -0
  12. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations1.png +0 -0
  13. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations10.png +0 -0
  14. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations11.png +0 -0
  15. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations12.png +0 -0
  16. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations13.png +0 -0
  17. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations2.png +0 -0
  18. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations3.png +0 -0
  19. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations4.png +0 -0
  20. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations5.png +0 -0
  21. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations6.png +0 -0
  22. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations7.png +0 -0
  23. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations8.png +0 -0
  24. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations9.png +0 -0
  25. invocation_tree-0.0.6/images/students.gif +0 -0
  26. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students.py +4 -3
  27. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students1.png +0 -0
  28. invocation_tree-0.0.6/images/students10.png +0 -0
  29. invocation_tree-0.0.6/images/students11.png +0 -0
  30. invocation_tree-0.0.6/images/students12.png +0 -0
  31. invocation_tree-0.0.6/images/students13.png +0 -0
  32. invocation_tree-0.0.6/images/students14.png +0 -0
  33. invocation_tree-0.0.6/images/students15.png +0 -0
  34. invocation_tree-0.0.6/images/students2.png +0 -0
  35. invocation_tree-0.0.6/images/students3.png +0 -0
  36. invocation_tree-0.0.6/images/students4.png +0 -0
  37. invocation_tree-0.0.6/images/students5.png +0 -0
  38. invocation_tree-0.0.6/images/students6.png +0 -0
  39. invocation_tree-0.0.6/images/students7.png +0 -0
  40. invocation_tree-0.0.6/images/students8.png +0 -0
  41. invocation_tree-0.0.6/images/students9.png +0 -0
  42. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/invocation_tree/__init__.py +6 -6
  43. {invocation_tree-0.0.4 → invocation_tree-0.0.6/invocation_tree.egg-info}/PKG-INFO +25 -14
  44. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/invocation_tree.egg-info/SOURCES.txt +2 -0
  45. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/setup.py +1 -1
  46. invocation_tree-0.0.4/images/students.gif +0 -0
  47. invocation_tree-0.0.4/images/students10.png +0 -0
  48. invocation_tree-0.0.4/images/students11.png +0 -0
  49. invocation_tree-0.0.4/images/students12.png +0 -0
  50. invocation_tree-0.0.4/images/students13.png +0 -0
  51. invocation_tree-0.0.4/images/students14.png +0 -0
  52. invocation_tree-0.0.4/images/students15.png +0 -0
  53. invocation_tree-0.0.4/images/students2.png +0 -0
  54. invocation_tree-0.0.4/images/students3.png +0 -0
  55. invocation_tree-0.0.4/images/students4.png +0 -0
  56. invocation_tree-0.0.4/images/students5.png +0 -0
  57. invocation_tree-0.0.4/images/students6.png +0 -0
  58. invocation_tree-0.0.4/images/students7.png +0 -0
  59. invocation_tree-0.0.4/images/students8.png +0 -0
  60. invocation_tree-0.0.4/images/students9.png +0 -0
  61. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/LICENSE.txt +0 -0
  62. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/MANIFEST.in +0 -0
  63. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/create_gif.sh +0 -0
  64. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/create_images.sh +0 -0
  65. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/create_images.sh~ +0 -0
  66. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial.gif +0 -0
  67. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial.py +0 -0
  68. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial.py~ +0 -0
  69. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial8.gv +0 -0
  70. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/factorial9.gv +0 -0
  71. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/invocation_tree.pdf +0 -0
  72. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/invocation_tree0.pdf +0 -0
  73. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations.gif +0 -0
  74. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations.py +0 -0
  75. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations.py~ +0 -0
  76. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/permutations22.png~ +0 -0
  77. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/student.gif +0 -0
  78. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students.py~ +0 -0
  79. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students16.gv +0 -0
  80. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students17.gv +0 -0
  81. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students18.gv +0 -0
  82. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students19.gv +0 -0
  83. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students20.gv +0 -0
  84. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students21.gv +0 -0
  85. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students22.gv +0 -0
  86. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students23.gv +0 -0
  87. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students24.gv +0 -0
  88. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students25.gv +0 -0
  89. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students26.gv +0 -0
  90. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students27.gv +0 -0
  91. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students28.gv +0 -0
  92. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students29.gv +0 -0
  93. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/students30.gv +0 -0
  94. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/test.py +0 -0
  95. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree0.gv +0 -0
  96. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree1.gv +0 -0
  97. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree10.gv +0 -0
  98. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree11.gv +0 -0
  99. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree12.gv +0 -0
  100. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree13.gv +0 -0
  101. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree14.gv +0 -0
  102. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree15.gv +0 -0
  103. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree16.gv +0 -0
  104. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree17.gv +0 -0
  105. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree2.gv +0 -0
  106. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree3.gv +0 -0
  107. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree4.gv +0 -0
  108. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree5.gv +0 -0
  109. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree6.gv +0 -0
  110. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree7.gv +0 -0
  111. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree8.gv +0 -0
  112. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/tree9.gv +0 -0
  113. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/images/vscode.png +0 -0
  114. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/install.txt +0 -0
  115. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/invocation_tree.egg-info/dependency_links.txt +0 -0
  116. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/invocation_tree.egg-info/requires.txt +0 -0
  117. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/invocation_tree.egg-info/top_level.txt +0 -0
  118. {invocation_tree-0.0.4 → invocation_tree-0.0.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: invocation_tree
3
- Version: 0.0.4
3
+ Version: 0.0.6
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
@@ -45,12 +45,13 @@ def compute_average(grades):
45
45
  return my_round(average, 1)
46
46
 
47
47
  def my_round(value, digits=0):
48
- shift = 10 ** digits
49
- return math.floor(value * shift + 0.5) / shift
48
+ """ High-precision half-up rounding of 'value' to a specified number of 'digits'. """
49
+ return float(Decimal(str(value)).quantize(Decimal(f"1e-{digits}"),
50
+ rounding=ROUND_HALF_UP))
50
51
 
51
- def passing_students(avg):
52
+ def passing_students(averages):
52
53
  return [student
53
- for student, average in avg.items()
54
+ for student, average in averages.items()
54
55
  if average >= 5.5]
55
56
 
56
57
  if __name__ == '__main__':
@@ -59,7 +60,7 @@ if __name__ == '__main__':
59
60
  ```
60
61
  ![invocation tree](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/students.gif)
61
62
 
62
- Each node in the tree represents a function call, and node's color indicates its state:
63
+ Each node in the tree represents a function call, and the node's color indicates its state:
63
64
 
64
65
  - White: The function is currently being executed (it is at the top of the call stack).
65
66
  - Green: The function is paused and will resume execution later (it is lower down on the call stack).
@@ -67,10 +68,8 @@ Each node in the tree represents a function call, and node's color indicates its
67
68
 
68
69
  For every function, the package displays its **local variables** and **return value**. Changes to these values over time are highlighted using bold text and gray shading to make them easy to track.
69
70
 
70
- The [invocation_tree](https://pypi.org/project/invocation-tree/) package visualizes function calls at different moments in time. If you want a more detailed visualization of your data at the current time, check out the [memory_graph](https://pypi.org/project/memory-graph/) package.
71
-
72
71
  ## Blocking ##
73
- The program blocks execution at every function call and return statement, printing the current location in the source code. Press the <Enter> key to continue execution. To block at every line of the program (like in a debugger tool) where a change of value occured, use instead:
72
+ The program blocks execution at every function call and return statement, printing the current location in the source code. Press the <Enter> key to continue execution. To block at every line of the program (like in a debugger tool) and only where a change of value occured, use instead:
74
73
 
75
74
  ```python
76
75
  tree = invo_tree.blocking_each_line()
@@ -98,7 +97,7 @@ def factorial(n):
98
97
  return n * factorial(n - 1)
99
98
 
100
99
  tree = invo_tree.blocking()
101
- tree(factorial, 4) # show invocation tree of calling factorial(4)
100
+ print( tree(factorial, 4) ) # show invocation tree of calling factorial(4)
102
101
  ```
103
102
  ![factorial](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/factorial.gif)
104
103
 
@@ -121,7 +120,7 @@ print(result) # all permutations of going Left and Right of length 2
121
120
  ```
122
121
  ![permutations](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/permutations.gif)
123
122
 
124
- ## Hide variables ##
123
+ ## Hide Variables ##
125
124
  In an educational context it can be useful to hide certian variables to avoid unnecessary complexity. This can for example be done with:
126
125
 
127
126
  ```python
@@ -167,12 +166,24 @@ tree = invo_tree.Invocation_Tree()
167
166
 
168
167
  For convenience we provide these functions to set common configurations:
169
168
 
170
- - **invo_tree.blocking()**, for blocking on function call and return
171
- - **invo_tree.blocking_each_line()**, for blocking on each line of the program
172
- - **invo_tree.debugger()**, for use in debugger tool (open 'tree.pdf') manually
169
+ - **invo_tree.blocking(filename)**, for blocking on function call and return
170
+ - **invo_tree.blocking_each_line(filename)**, for blocking on each line of the program
171
+ - **invo_tree.debugger(filename)**, for use in debugger tool (open <filename> manually)
173
172
  - **invo_tree.gif(filename)**, for generating many output files on function call and return for gif creation
174
173
  - **invo_tree.gif_each_line(filename)**, for generating many output files on each line for gif creation
175
174
 
176
175
  # Troubleshooting #
177
176
 
178
177
  - 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/).
178
+
179
+ ## Memory_Graph Package ##
180
+ 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.
181
+
182
+ # Author #
183
+ Bas Terwijn
184
+
185
+ # Inspiration #
186
+ Inspired by [rcviz](https://github.com/carlsborg/rcviz).
187
+
188
+ # Supported by #
189
+ <img src="https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/uva.png" alt="University of Amsterdam" width="600">
@@ -26,12 +26,13 @@ def compute_average(grades):
26
26
  return my_round(average, 1)
27
27
 
28
28
  def my_round(value, digits=0):
29
- shift = 10 ** digits
30
- return math.floor(value * shift + 0.5) / shift
29
+ """ High-precision half-up rounding of 'value' to a specified number of 'digits'. """
30
+ return float(Decimal(str(value)).quantize(Decimal(f"1e-{digits}"),
31
+ rounding=ROUND_HALF_UP))
31
32
 
32
- def passing_students(avg):
33
+ def passing_students(averages):
33
34
  return [student
34
- for student, average in avg.items()
35
+ for student, average in averages.items()
35
36
  if average >= 5.5]
36
37
 
37
38
  if __name__ == '__main__':
@@ -40,7 +41,7 @@ if __name__ == '__main__':
40
41
  ```
41
42
  ![invocation tree](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/students.gif)
42
43
 
43
- Each node in the tree represents a function call, and node's color indicates its state:
44
+ Each node in the tree represents a function call, and the node's color indicates its state:
44
45
 
45
46
  - White: The function is currently being executed (it is at the top of the call stack).
46
47
  - Green: The function is paused and will resume execution later (it is lower down on the call stack).
@@ -48,10 +49,8 @@ Each node in the tree represents a function call, and node's color indicates its
48
49
 
49
50
  For every function, the package displays its **local variables** and **return value**. Changes to these values over time are highlighted using bold text and gray shading to make them easy to track.
50
51
 
51
- The [invocation_tree](https://pypi.org/project/invocation-tree/) package visualizes function calls at different moments in time. If you want a more detailed visualization of your data at the current time, check out the [memory_graph](https://pypi.org/project/memory-graph/) package.
52
-
53
52
  ## Blocking ##
54
- The program blocks execution at every function call and return statement, printing the current location in the source code. Press the &lt;Enter&gt; key to continue execution. To block at every line of the program (like in a debugger tool) where a change of value occured, use instead:
53
+ The program blocks execution at every function call and return statement, printing the current location in the source code. Press the &lt;Enter&gt; key to continue execution. To block at every line of the program (like in a debugger tool) and only where a change of value occured, use instead:
55
54
 
56
55
  ```python
57
56
  tree = invo_tree.blocking_each_line()
@@ -79,7 +78,7 @@ def factorial(n):
79
78
  return n * factorial(n - 1)
80
79
 
81
80
  tree = invo_tree.blocking()
82
- tree(factorial, 4) # show invocation tree of calling factorial(4)
81
+ print( tree(factorial, 4) ) # show invocation tree of calling factorial(4)
83
82
  ```
84
83
  ![factorial](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/factorial.gif)
85
84
 
@@ -102,7 +101,7 @@ print(result) # all permutations of going Left and Right of length 2
102
101
  ```
103
102
  ![permutations](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/permutations.gif)
104
103
 
105
- ## Hide variables ##
104
+ ## Hide Variables ##
106
105
  In an educational context it can be useful to hide certian variables to avoid unnecessary complexity. This can for example be done with:
107
106
 
108
107
  ```python
@@ -148,12 +147,24 @@ tree = invo_tree.Invocation_Tree()
148
147
 
149
148
  For convenience we provide these functions to set common configurations:
150
149
 
151
- - **invo_tree.blocking()**, for blocking on function call and return
152
- - **invo_tree.blocking_each_line()**, for blocking on each line of the program
153
- - **invo_tree.debugger()**, for use in debugger tool (open 'tree.pdf') manually
150
+ - **invo_tree.blocking(filename)**, for blocking on function call and return
151
+ - **invo_tree.blocking_each_line(filename)**, for blocking on each line of the program
152
+ - **invo_tree.debugger(filename)**, for use in debugger tool (open &lt;filename&gt; manually)
154
153
  - **invo_tree.gif(filename)**, for generating many output files on function call and return for gif creation
155
154
  - **invo_tree.gif_each_line(filename)**, for generating many output files on each line for gif creation
156
155
 
157
156
  # Troubleshooting #
158
157
 
159
158
  - 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/).
159
+
160
+ ## Memory_Graph Package ##
161
+ 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.
162
+
163
+ # Author #
164
+ Bas Terwijn
165
+
166
+ # Inspiration #
167
+ Inspired by [rcviz](https://github.com/carlsborg/rcviz).
168
+
169
+ # Supported by #
170
+ <img src="https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/uva.png" alt="University of Amsterdam" width="600">
@@ -1,5 +1,5 @@
1
1
  import invocation_tree as invo_tree
2
- import math
2
+ from decimal import Decimal, ROUND_HALF_UP
3
3
 
4
4
  def main():
5
5
  students = {'Ann':[7.5, 8.0],
@@ -15,8 +15,9 @@ def compute_average(grades):
15
15
  return my_round(average, 1)
16
16
 
17
17
  def my_round(value, digits=0):
18
- shift = 10 ** digits
19
- return math.floor(value * shift + 0.5) / shift
18
+ """ High-precision half-up rounding of 'value' to a specified number of 'digits'. """
19
+ return float(Decimal(str(value)).quantize(Decimal(f"1e-{digits}"),
20
+ rounding=ROUND_HALF_UP))
20
21
 
21
22
  def passing_students(avg):
22
23
  return [student
@@ -7,7 +7,7 @@ import html
7
7
  import sys
8
8
  import difflib
9
9
 
10
- __version__ = "0.0.4"
10
+ __version__ = "0.0.6"
11
11
  __author__ = 'Bas Terwijn'
12
12
 
13
13
  def highlight_diff(str1, str2):
@@ -261,13 +261,13 @@ class Invocation_Tree:
261
261
  self.output_graph(frame, event)
262
262
  return self.trace_calls
263
263
 
264
- def blocking():
265
- return Invocation_Tree()
264
+ def blocking(filename='tree.pdf'):
265
+ return Invocation_Tree(filename=filename)
266
266
 
267
- def blocking_each_line():
268
- return Invocation_Tree(each_line=True)
267
+ def blocking_each_line(filename='tree.pdf'):
268
+ return Invocation_Tree(filename=filename, each_line=True)
269
269
 
270
- def debugger():
270
+ def debugger(filename='tree.pdf'):
271
271
  return Invocation_Tree(show=False, block=False, each_line=True)
272
272
 
273
273
  def gif(filename='tree.png'):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: invocation_tree
3
- Version: 0.0.4
3
+ Version: 0.0.6
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
@@ -45,12 +45,13 @@ def compute_average(grades):
45
45
  return my_round(average, 1)
46
46
 
47
47
  def my_round(value, digits=0):
48
- shift = 10 ** digits
49
- return math.floor(value * shift + 0.5) / shift
48
+ """ High-precision half-up rounding of 'value' to a specified number of 'digits'. """
49
+ return float(Decimal(str(value)).quantize(Decimal(f"1e-{digits}"),
50
+ rounding=ROUND_HALF_UP))
50
51
 
51
- def passing_students(avg):
52
+ def passing_students(averages):
52
53
  return [student
53
- for student, average in avg.items()
54
+ for student, average in averages.items()
54
55
  if average >= 5.5]
55
56
 
56
57
  if __name__ == '__main__':
@@ -59,7 +60,7 @@ if __name__ == '__main__':
59
60
  ```
60
61
  ![invocation tree](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/students.gif)
61
62
 
62
- Each node in the tree represents a function call, and node's color indicates its state:
63
+ Each node in the tree represents a function call, and the node's color indicates its state:
63
64
 
64
65
  - White: The function is currently being executed (it is at the top of the call stack).
65
66
  - Green: The function is paused and will resume execution later (it is lower down on the call stack).
@@ -67,10 +68,8 @@ Each node in the tree represents a function call, and node's color indicates its
67
68
 
68
69
  For every function, the package displays its **local variables** and **return value**. Changes to these values over time are highlighted using bold text and gray shading to make them easy to track.
69
70
 
70
- The [invocation_tree](https://pypi.org/project/invocation-tree/) package visualizes function calls at different moments in time. If you want a more detailed visualization of your data at the current time, check out the [memory_graph](https://pypi.org/project/memory-graph/) package.
71
-
72
71
  ## Blocking ##
73
- The program blocks execution at every function call and return statement, printing the current location in the source code. Press the &lt;Enter&gt; key to continue execution. To block at every line of the program (like in a debugger tool) where a change of value occured, use instead:
72
+ The program blocks execution at every function call and return statement, printing the current location in the source code. Press the &lt;Enter&gt; key to continue execution. To block at every line of the program (like in a debugger tool) and only where a change of value occured, use instead:
74
73
 
75
74
  ```python
76
75
  tree = invo_tree.blocking_each_line()
@@ -98,7 +97,7 @@ def factorial(n):
98
97
  return n * factorial(n - 1)
99
98
 
100
99
  tree = invo_tree.blocking()
101
- tree(factorial, 4) # show invocation tree of calling factorial(4)
100
+ print( tree(factorial, 4) ) # show invocation tree of calling factorial(4)
102
101
  ```
103
102
  ![factorial](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/factorial.gif)
104
103
 
@@ -121,7 +120,7 @@ print(result) # all permutations of going Left and Right of length 2
121
120
  ```
122
121
  ![permutations](https://raw.githubusercontent.com/bterwijn/invocation_tree/main/images/permutations.gif)
123
122
 
124
- ## Hide variables ##
123
+ ## Hide Variables ##
125
124
  In an educational context it can be useful to hide certian variables to avoid unnecessary complexity. This can for example be done with:
126
125
 
127
126
  ```python
@@ -167,12 +166,24 @@ tree = invo_tree.Invocation_Tree()
167
166
 
168
167
  For convenience we provide these functions to set common configurations:
169
168
 
170
- - **invo_tree.blocking()**, for blocking on function call and return
171
- - **invo_tree.blocking_each_line()**, for blocking on each line of the program
172
- - **invo_tree.debugger()**, for use in debugger tool (open 'tree.pdf') manually
169
+ - **invo_tree.blocking(filename)**, for blocking on function call and return
170
+ - **invo_tree.blocking_each_line(filename)**, for blocking on each line of the program
171
+ - **invo_tree.debugger(filename)**, for use in debugger tool (open &lt;filename&gt; manually)
173
172
  - **invo_tree.gif(filename)**, for generating many output files on function call and return for gif creation
174
173
  - **invo_tree.gif_each_line(filename)**, for generating many output files on each line for gif creation
175
174
 
176
175
  # Troubleshooting #
177
176
 
178
177
  - 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/).
178
+
179
+ ## Memory_Graph Package ##
180
+ 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.
181
+
182
+ # Author #
183
+ Bas Terwijn
184
+
185
+ # Inspiration #
186
+ Inspired by [rcviz](https://github.com/carlsborg/rcviz).
187
+
188
+ # Supported by #
189
+ <img src="https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/uva.png" alt="University of Amsterdam" width="600">
@@ -9,6 +9,7 @@ images/create_images.sh~
9
9
  images/factorial.gif
10
10
  images/factorial.py
11
11
  images/factorial.py~
12
+ images/factorial0.png
12
13
  images/factorial1.png
13
14
  images/factorial2.png
14
15
  images/factorial3.png
@@ -23,6 +24,7 @@ images/invocation_tree0.pdf
23
24
  images/permutations.gif
24
25
  images/permutations.py
25
26
  images/permutations.py~
27
+ images/permutations0.png
26
28
  images/permutations1.png
27
29
  images/permutations10.png
28
30
  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.4',
14
+ version = '0.0.6',
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