memory-graph 0.3.67__tar.gz → 0.3.68__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 (41) hide show
  1. {memory_graph-0.3.67 → memory_graph-0.3.68}/PKG-INFO +48 -4
  2. {memory_graph-0.3.67 → memory_graph-0.3.68}/README.md +47 -3
  3. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/__init__.py +11 -1
  4. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph.egg-info/PKG-INFO +48 -4
  5. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph.egg-info/SOURCES.txt +1 -0
  6. {memory_graph-0.3.67 → memory_graph-0.3.68}/pyproject.toml +1 -1
  7. memory_graph-0.3.68/setup.py +7 -0
  8. {memory_graph-0.3.67 → memory_graph-0.3.68}/LICENSE.txt +0 -0
  9. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/call_stack.py +0 -0
  10. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/config.py +0 -0
  11. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/config_default.py +0 -0
  12. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/config_helpers.py +0 -0
  13. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/extension_numpy.py +0 -0
  14. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/extension_pandas.py +0 -0
  15. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/extension_torch.py +0 -0
  16. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/html_table.py +0 -0
  17. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/list_view.py +0 -0
  18. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/memory_to_nodes.py +0 -0
  19. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/node_base.py +0 -0
  20. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/node_key_value.py +0 -0
  21. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/node_leaf.py +0 -0
  22. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/node_linear.py +0 -0
  23. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/node_table.py +0 -0
  24. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/sequence.py +0 -0
  25. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/slicer.py +0 -0
  26. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/slices.py +0 -0
  27. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/slices_iterator.py +0 -0
  28. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/slices_table_iterator.py +0 -0
  29. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test.py +0 -0
  30. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test_max_graph_depth.py +0 -0
  31. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test_memory_graph.py +0 -0
  32. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test_memory_to_nodes.py +0 -0
  33. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test_sequence.py +0 -0
  34. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test_slicer.py +0 -0
  35. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test_slices.py +0 -0
  36. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/test_slices_iterator.py +0 -0
  37. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph/utils.py +0 -0
  38. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph.egg-info/dependency_links.txt +0 -0
  39. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph.egg-info/requires.txt +0 -0
  40. {memory_graph-0.3.67 → memory_graph-0.3.68}/memory_graph.egg-info/top_level.txt +0 -0
  41. {memory_graph-0.3.67 → memory_graph-0.3.68}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memory_graph
3
- Version: 0.3.67
3
+ Version: 0.3.68
4
4
  Summary: Teaching tool and debugging aid in context of references, mutable data types, and shallow and deep copy.
5
5
  Author-email: Bas Terwijn <bterwijn@gmail.com>
6
6
  License-Expression: BSD-2-Clause
@@ -176,7 +176,7 @@ ___
176
176
  # Python Data Model #
177
177
  Learn the right **mental model** to think about Python data. The [Python Data Model](https://docs.python.org/3/reference/datamodel.html) makes a distiction between immutable and mutable types:
178
178
 
179
- * **immutable**: bool, int, float, complex, str, tuple, bytes, frozenset
179
+ * **immutable**: bool, int, float, complex, str, tuple, frozenset, frozendict, bytes
180
180
  * **mutable**: list, set, dict, classes, ... (most other types)
181
181
 
182
182
 
@@ -557,6 +557,48 @@ and pressing &lt;Enter&gt; a number of times, results in:
557
557
 
558
558
  ![debugging.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/debugging.gif)
559
559
 
560
+ ## Debugging using Exceptions ##
561
+
562
+ To get the call stack at the point where exception `e` was thrown use `mg.stack_exception(e)`. This allows you to graph the trace back for easier debugging, for example:
563
+
564
+ ``` python
565
+ import memory_graph as mg
566
+ import traceback;
567
+
568
+ def fun3():
569
+ d = [0] * 3
570
+ for i in range(4):
571
+ d[i] = i # throws IndexError when i = 3
572
+
573
+ def fun2():
574
+ fun3()
575
+
576
+ def fun1():
577
+ fun2()
578
+
579
+ try:
580
+ fun1()
581
+ except Exception as e:
582
+ traceback.print_exc() # print trace back
583
+ mg.show(mg.stack_exception(e)) # graph trace back
584
+ ```
585
+ ```
586
+ $ python exception_example.py
587
+ Traceback (most recent call last):
588
+ File "exception_example.py", line 16, in <module>
589
+ fun1()
590
+ File "exception_example.py", line 13, in fun1
591
+ fun2()
592
+ File "exception_example.py", line 10, in fun2
593
+ fun3()
594
+ File "exception_example.py", line 7, in fun3
595
+ d[i] = i # throws IndexError when i = 3
596
+ ~^^^
597
+ IndexError: list assignment index out of range
598
+ ```
599
+ ![exception_example.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/exception_example.png)
600
+
601
+
560
602
  # Data Structure Examples #
561
603
  Package memory_graph can **visualize the structure of your data** to easily understand and debug data structures, some examples:
562
604
 
@@ -696,6 +738,8 @@ Visualization of different sorting algorithms in Memory Graph Web Debugger.
696
738
  - [insertion sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/insertion_sort.py&breakpoints=13,29&continues=1&timestep=0.2&play)
697
739
  - [bubble sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bubble_sort.py&breakpoints=29,38&continues=1&timestep=0.2&play)
698
740
  - [cocktail shaker sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/cocktail_sort.py&breakpoints=16,45&continues=1&timestep=0.2&play)
741
+ - [bucket sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bucket_sort.py&timestep=0.2&play)
742
+ - [radix sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/radix_sort.py&timestep=0.2&play)
699
743
 
700
744
 
701
745
  # Bitwise Operators #
@@ -710,7 +754,7 @@ In this configuration example we show the decimal, binary and [two's complement
710
754
 
711
755
  A sliding puzzle solver as a challenging example showing how memory_graph deals with large amounts of data. Click "Continue" to step through the breadth-first search generations until a solution path is found:
712
756
 
713
- - [sliding puzzle solver](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/sliding_puzzle.py&breakpoints=17,27,29,40&continues=1)
757
+ - [sliding puzzle solver](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/sliding_puzzle.py&breakpoints=16,26,28,39&continues=1)
714
758
 
715
759
  ![sliding_puzzle.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/sliding_puzzle.png)
716
760
 
@@ -1050,7 +1094,7 @@ import memory_graph as mg
1050
1094
 
1051
1095
  data = []
1052
1096
  x = ['x']
1053
- for i in range(20):
1097
+ for i in range(35):
1054
1098
  data.append(x)
1055
1099
 
1056
1100
  mg.show(locals())
@@ -156,7 +156,7 @@ ___
156
156
  # Python Data Model #
157
157
  Learn the right **mental model** to think about Python data. The [Python Data Model](https://docs.python.org/3/reference/datamodel.html) makes a distiction between immutable and mutable types:
158
158
 
159
- * **immutable**: bool, int, float, complex, str, tuple, bytes, frozenset
159
+ * **immutable**: bool, int, float, complex, str, tuple, frozenset, frozendict, bytes
160
160
  * **mutable**: list, set, dict, classes, ... (most other types)
161
161
 
162
162
 
@@ -537,6 +537,48 @@ and pressing &lt;Enter&gt; a number of times, results in:
537
537
 
538
538
  ![debugging.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/debugging.gif)
539
539
 
540
+ ## Debugging using Exceptions ##
541
+
542
+ To get the call stack at the point where exception `e` was thrown use `mg.stack_exception(e)`. This allows you to graph the trace back for easier debugging, for example:
543
+
544
+ ``` python
545
+ import memory_graph as mg
546
+ import traceback;
547
+
548
+ def fun3():
549
+ d = [0] * 3
550
+ for i in range(4):
551
+ d[i] = i # throws IndexError when i = 3
552
+
553
+ def fun2():
554
+ fun3()
555
+
556
+ def fun1():
557
+ fun2()
558
+
559
+ try:
560
+ fun1()
561
+ except Exception as e:
562
+ traceback.print_exc() # print trace back
563
+ mg.show(mg.stack_exception(e)) # graph trace back
564
+ ```
565
+ ```
566
+ $ python exception_example.py
567
+ Traceback (most recent call last):
568
+ File "exception_example.py", line 16, in <module>
569
+ fun1()
570
+ File "exception_example.py", line 13, in fun1
571
+ fun2()
572
+ File "exception_example.py", line 10, in fun2
573
+ fun3()
574
+ File "exception_example.py", line 7, in fun3
575
+ d[i] = i # throws IndexError when i = 3
576
+ ~^^^
577
+ IndexError: list assignment index out of range
578
+ ```
579
+ ![exception_example.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/exception_example.png)
580
+
581
+
540
582
  # Data Structure Examples #
541
583
  Package memory_graph can **visualize the structure of your data** to easily understand and debug data structures, some examples:
542
584
 
@@ -676,6 +718,8 @@ Visualization of different sorting algorithms in Memory Graph Web Debugger.
676
718
  - [insertion sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/insertion_sort.py&breakpoints=13,29&continues=1&timestep=0.2&play)
677
719
  - [bubble sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bubble_sort.py&breakpoints=29,38&continues=1&timestep=0.2&play)
678
720
  - [cocktail shaker sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/cocktail_sort.py&breakpoints=16,45&continues=1&timestep=0.2&play)
721
+ - [bucket sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bucket_sort.py&timestep=0.2&play)
722
+ - [radix sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/radix_sort.py&timestep=0.2&play)
679
723
 
680
724
 
681
725
  # Bitwise Operators #
@@ -690,7 +734,7 @@ In this configuration example we show the decimal, binary and [two's complement
690
734
 
691
735
  A sliding puzzle solver as a challenging example showing how memory_graph deals with large amounts of data. Click "Continue" to step through the breadth-first search generations until a solution path is found:
692
736
 
693
- - [sliding puzzle solver](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/sliding_puzzle.py&breakpoints=17,27,29,40&continues=1)
737
+ - [sliding puzzle solver](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/sliding_puzzle.py&breakpoints=16,26,28,39&continues=1)
694
738
 
695
739
  ![sliding_puzzle.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/sliding_puzzle.png)
696
740
 
@@ -1030,7 +1074,7 @@ import memory_graph as mg
1030
1074
 
1031
1075
  data = []
1032
1076
  x = ['x']
1033
- for i in range(20):
1077
+ for i in range(35):
1034
1078
  data.append(x)
1035
1079
 
1036
1080
  mg.show(locals())
@@ -2,7 +2,7 @@
2
2
  # Copyright (c) 2023, Bas Terwijn.
3
3
  # SPDX-License-Identifier: BSD-2-Clause
4
4
 
5
- __version__ = "0.3.67"
5
+ __version__ = "0.3.68"
6
6
  __author__ = 'Bas Terwijn'
7
7
 
8
8
  import memory_graph.memory_to_nodes as memory_to_nodes
@@ -13,6 +13,7 @@ import memory_graph.utils as utils
13
13
  import inspect
14
14
  import sys
15
15
  import itertools as it
16
+ import types
16
17
  from memory_graph.call_stack import call_stack
17
18
 
18
19
  import graphviz
@@ -289,6 +290,15 @@ def stack_multi_slice(drop_functions : List[Tuple[str, int]] = [],
289
290
  def stack(end_functions=["<module>"], stack_index=0):
290
291
  return stack_slice([], end_functions, stack_index+2)
291
292
 
293
+ def stack_exception(exception):
294
+ """ Get the call stack at the point 'exception' was thrown. """
295
+ tb = exception.__traceback__
296
+ frame_infos = []
297
+ while tb is not None:
298
+ frame_infos.append(types.SimpleNamespace(frame=tb.tb_frame))
299
+ tb = tb.tb_next
300
+ return stack_frames_to_dict(frame_infos)
301
+
292
302
  def stack_pdb(begin_functions=[("trace_dispatch",1)],
293
303
  end_functions=["<module>"],
294
304
  stack_index=0):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memory_graph
3
- Version: 0.3.67
3
+ Version: 0.3.68
4
4
  Summary: Teaching tool and debugging aid in context of references, mutable data types, and shallow and deep copy.
5
5
  Author-email: Bas Terwijn <bterwijn@gmail.com>
6
6
  License-Expression: BSD-2-Clause
@@ -176,7 +176,7 @@ ___
176
176
  # Python Data Model #
177
177
  Learn the right **mental model** to think about Python data. The [Python Data Model](https://docs.python.org/3/reference/datamodel.html) makes a distiction between immutable and mutable types:
178
178
 
179
- * **immutable**: bool, int, float, complex, str, tuple, bytes, frozenset
179
+ * **immutable**: bool, int, float, complex, str, tuple, frozenset, frozendict, bytes
180
180
  * **mutable**: list, set, dict, classes, ... (most other types)
181
181
 
182
182
 
@@ -557,6 +557,48 @@ and pressing &lt;Enter&gt; a number of times, results in:
557
557
 
558
558
  ![debugging.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/debugging.gif)
559
559
 
560
+ ## Debugging using Exceptions ##
561
+
562
+ To get the call stack at the point where exception `e` was thrown use `mg.stack_exception(e)`. This allows you to graph the trace back for easier debugging, for example:
563
+
564
+ ``` python
565
+ import memory_graph as mg
566
+ import traceback;
567
+
568
+ def fun3():
569
+ d = [0] * 3
570
+ for i in range(4):
571
+ d[i] = i # throws IndexError when i = 3
572
+
573
+ def fun2():
574
+ fun3()
575
+
576
+ def fun1():
577
+ fun2()
578
+
579
+ try:
580
+ fun1()
581
+ except Exception as e:
582
+ traceback.print_exc() # print trace back
583
+ mg.show(mg.stack_exception(e)) # graph trace back
584
+ ```
585
+ ```
586
+ $ python exception_example.py
587
+ Traceback (most recent call last):
588
+ File "exception_example.py", line 16, in <module>
589
+ fun1()
590
+ File "exception_example.py", line 13, in fun1
591
+ fun2()
592
+ File "exception_example.py", line 10, in fun2
593
+ fun3()
594
+ File "exception_example.py", line 7, in fun3
595
+ d[i] = i # throws IndexError when i = 3
596
+ ~^^^
597
+ IndexError: list assignment index out of range
598
+ ```
599
+ ![exception_example.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/exception_example.png)
600
+
601
+
560
602
  # Data Structure Examples #
561
603
  Package memory_graph can **visualize the structure of your data** to easily understand and debug data structures, some examples:
562
604
 
@@ -696,6 +738,8 @@ Visualization of different sorting algorithms in Memory Graph Web Debugger.
696
738
  - [insertion sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/insertion_sort.py&breakpoints=13,29&continues=1&timestep=0.2&play)
697
739
  - [bubble sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bubble_sort.py&breakpoints=29,38&continues=1&timestep=0.2&play)
698
740
  - [cocktail shaker sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/cocktail_sort.py&breakpoints=16,45&continues=1&timestep=0.2&play)
741
+ - [bucket sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bucket_sort.py&timestep=0.2&play)
742
+ - [radix sort](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/radix_sort.py&timestep=0.2&play)
699
743
 
700
744
 
701
745
  # Bitwise Operators #
@@ -710,7 +754,7 @@ In this configuration example we show the decimal, binary and [two's complement
710
754
 
711
755
  A sliding puzzle solver as a challenging example showing how memory_graph deals with large amounts of data. Click "Continue" to step through the breadth-first search generations until a solution path is found:
712
756
 
713
- - [sliding puzzle solver](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/sliding_puzzle.py&breakpoints=17,27,29,40&continues=1)
757
+ - [sliding puzzle solver](https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/sliding_puzzle.py&breakpoints=16,26,28,39&continues=1)
714
758
 
715
759
  ![sliding_puzzle.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/sliding_puzzle.png)
716
760
 
@@ -1050,7 +1094,7 @@ import memory_graph as mg
1050
1094
 
1051
1095
  data = []
1052
1096
  x = ['x']
1053
- for i in range(20):
1097
+ for i in range(35):
1054
1098
  data.append(x)
1055
1099
 
1056
1100
  mg.show(locals())
@@ -1,6 +1,7 @@
1
1
  LICENSE.txt
2
2
  README.md
3
3
  pyproject.toml
4
+ setup.py
4
5
  memory_graph/__init__.py
5
6
  memory_graph/call_stack.py
6
7
  memory_graph/config.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "memory_graph"
7
- version = "0.3.67"
7
+ version = "0.3.68"
8
8
  description = "Teaching tool and debugging aid in context of references, mutable data types, and shallow and deep copy."
9
9
  authors = [
10
10
  {name = "Bas Terwijn", email = "bterwijn@gmail.com"}
@@ -0,0 +1,7 @@
1
+ from setuptools import setup
2
+
3
+ setup(
4
+ name="memory-graph",
5
+ version="0.3.30",
6
+ packages=["memory_graph"],
7
+ )
File without changes
File without changes