memory-graph 0.3.83__tar.gz → 0.3.85__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.
- {memory_graph-0.3.83 → memory_graph-0.3.85}/PKG-INFO +1 -1
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/__init__.py +1 -1
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/html_table.py +33 -15
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/memory_to_nodes.py +4 -2
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/node_key_value.py +2 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/node_linear.py +2 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/node_table.py +5 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/slices.py +6 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/slices_iterator.py +19 -4
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph.egg-info/PKG-INFO +1 -1
- {memory_graph-0.3.83 → memory_graph-0.3.85}/pyproject.toml +1 -1
- {memory_graph-0.3.83 → memory_graph-0.3.85}/LICENSE.txt +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/README.md +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/call_stack.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/config.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/config_default.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/config_helpers.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/extension_numpy.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/extension_pandas.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/extension_torch.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/list_view.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/node_base.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/node_leaf.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/sequence.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/slicer.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/slices_table_iterator.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test_max_graph_depth.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test_memory_graph.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test_memory_to_nodes.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test_sequence.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test_slicer.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test_slices.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/test_slices_iterator.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph/utils.py +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph.egg-info/SOURCES.txt +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph.egg-info/dependency_links.txt +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph.egg-info/requires.txt +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/memory_graph.egg-info/top_level.txt +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/setup.cfg +0 -0
- {memory_graph-0.3.83 → memory_graph-0.3.85}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memory_graph
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.85
|
|
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
|
|
@@ -6,11 +6,6 @@ import memory_graph.config as config
|
|
|
6
6
|
import memory_graph.config_helpers as config_helpers
|
|
7
7
|
import memory_graph.utils as utils
|
|
8
8
|
|
|
9
|
-
def html_table_frame(s, border, color, line_color='black', spacing=5):
|
|
10
|
-
""" Helper function to add the HTML table frame to the string s setting the 'border' and 'color'. """
|
|
11
|
-
return (f'<\n<TABLE BORDER="{border}" CELLBORDER="1" CELLSPACING="{spacing}" CELLPADDING="0" BGCOLOR="{color}" COLOR="{line_color}" PORT="table">\n <TR>' +
|
|
12
|
-
s + '</TR>\n</TABLE>\n>')
|
|
13
|
-
|
|
14
9
|
def format_string(value, quote_str):
|
|
15
10
|
""" Helper function to format 'value' to be shown in the graph. We escape html characters and convert newlines to <BR/> tags. """
|
|
16
11
|
to_string = config_helpers.get_to_string(value)
|
|
@@ -30,7 +25,7 @@ class HTML_Table:
|
|
|
30
25
|
"""
|
|
31
26
|
Create an HTML_Table object.
|
|
32
27
|
"""
|
|
33
|
-
self.
|
|
28
|
+
self.rows = [[]]
|
|
34
29
|
self.add_new_line_flag = False
|
|
35
30
|
self.is_empty = True
|
|
36
31
|
self.col_count = 0
|
|
@@ -38,10 +33,24 @@ class HTML_Table:
|
|
|
38
33
|
self.ref_count = 0
|
|
39
34
|
self.max_col_count = 0
|
|
40
35
|
self.edges = []
|
|
36
|
+
self.rows_reversed = False
|
|
37
|
+
self.columns_reversed = False
|
|
41
38
|
|
|
42
39
|
def __repr__(self):
|
|
43
40
|
""" Get the string representation of the HTML_Table object. """
|
|
44
|
-
return self.
|
|
41
|
+
return str(self.rows)
|
|
42
|
+
|
|
43
|
+
def add_row(self):
|
|
44
|
+
self.rows.append([])
|
|
45
|
+
|
|
46
|
+
def add_column(self, s):
|
|
47
|
+
self.rows[-1].append(s)
|
|
48
|
+
|
|
49
|
+
def reverse_rows(self, reversed=True):
|
|
50
|
+
self.rows_reversed = reversed
|
|
51
|
+
|
|
52
|
+
def reverse_columns(self, reversed=True):
|
|
53
|
+
self.columns_reversed = reversed
|
|
45
54
|
|
|
46
55
|
def add_new_line(self):
|
|
47
56
|
""" Set the 'add_new_line_flag' to add a new line to the table when adding the next table element. """
|
|
@@ -54,13 +63,13 @@ class HTML_Table:
|
|
|
54
63
|
def check_add_new_line(self):
|
|
55
64
|
""" Check if a new line should be added to the table, and if so add it and sets the 'add_new_line_flag' to False."""
|
|
56
65
|
if self.add_new_line_flag:
|
|
57
|
-
self.
|
|
66
|
+
self.add_row()
|
|
58
67
|
self.add_new_line_flag = False
|
|
59
68
|
|
|
60
69
|
def add_index(self, s):
|
|
61
70
|
""" Add an index s to the table. """
|
|
62
71
|
self.check_add_new_line()
|
|
63
|
-
self.
|
|
72
|
+
self.add_column(f'<TD BORDER="0"><font color="{config.index_color}">{str(s)}</font></TD>')
|
|
64
73
|
self.col_count += 1
|
|
65
74
|
|
|
66
75
|
def add_entry(self, node, nodes, child, id_to_slices, rounded=False, border=1, dashed=False, embed=False):
|
|
@@ -79,7 +88,7 @@ class HTML_Table:
|
|
|
79
88
|
""" Helper function to add 'value' to the table. """
|
|
80
89
|
self.check_add_new_line()
|
|
81
90
|
r = ' STYLE="ROUNDED"' if rounded else ''
|
|
82
|
-
self.
|
|
91
|
+
self.add_column(f'<TD BORDER="{border}"{r}>{format_string(value, not rounded)}</TD>')
|
|
83
92
|
self.is_empty = False
|
|
84
93
|
self.col_count += 1
|
|
85
94
|
|
|
@@ -87,7 +96,7 @@ class HTML_Table:
|
|
|
87
96
|
""" Helper function to add a reference to the table. """
|
|
88
97
|
self.check_add_new_line()
|
|
89
98
|
r = ' STYLE="ROUNDED"' if rounded else ''
|
|
90
|
-
self.
|
|
99
|
+
self.add_column(f'<TD BORDER="{border}" PORT="ref{self.ref_count}"{r}> </TD>')
|
|
91
100
|
self.edges.append( (f'{node.get_name()}:ref{self.ref_count}',
|
|
92
101
|
child.get_name(), dashed) )
|
|
93
102
|
self.ref_count += 1
|
|
@@ -97,17 +106,25 @@ class HTML_Table:
|
|
|
97
106
|
""" Helper function to add dots to the table. """
|
|
98
107
|
self.check_add_new_line()
|
|
99
108
|
r = 'STYLE="ROUNDED"' if rounded else ''
|
|
100
|
-
self.
|
|
109
|
+
self.add_column(f'<TD BORDER="{border}" {r}>...</TD>')
|
|
101
110
|
self.col_count += 1
|
|
102
111
|
|
|
112
|
+
def html_table_frame(self, border, color, line_color='black', spacing=5):
|
|
113
|
+
""" Helper function to add the HTML table frame to the string s setting the 'border' and 'color'. """
|
|
114
|
+
s = f'<\n<TABLE BORDER="{border}" CELLBORDER="1" CELLSPACING="{spacing}" CELLPADDING="0" BGCOLOR="{color}" COLOR="{line_color}" PORT="table">\n'
|
|
115
|
+
s += ''.join('<TR>' + ''.join(cell for cell in (reversed(row) if self.columns_reversed else row)) + '</TR>\n'
|
|
116
|
+
for row in (reversed(self.rows) if self.rows_reversed else self.rows))
|
|
117
|
+
s += '</TABLE>\n>'
|
|
118
|
+
return s
|
|
119
|
+
|
|
103
120
|
def to_string(self, border=1, color='white', line_color='black'):
|
|
104
121
|
""" Construct the HTML table string with the 'border' and 'color' settings. """
|
|
105
122
|
if self.col_count == 0 and self.row_count == 0:
|
|
106
123
|
if self.is_empty:
|
|
107
124
|
self.add_value(utils.unquoted_str(''), border=0)
|
|
108
|
-
return html_table_frame(
|
|
109
|
-
return html_table_frame(
|
|
110
|
-
|
|
125
|
+
return self.html_table_frame(border, color, line_color, spacing=0)
|
|
126
|
+
return self.html_table_frame(border, color, line_color)
|
|
127
|
+
|
|
111
128
|
def get_column(self):
|
|
112
129
|
""" Get the number of columns in the table. """
|
|
113
130
|
return self.col_count
|
|
@@ -128,6 +145,7 @@ if __name__ == '__main__':
|
|
|
128
145
|
table = HTML_Table()
|
|
129
146
|
rows = 4
|
|
130
147
|
columns = 5
|
|
148
|
+
#table.reverse_columns()
|
|
131
149
|
for r in range(rows):
|
|
132
150
|
for c in range(columns):
|
|
133
151
|
table.add_value(f'{c},{r}')
|
|
@@ -239,7 +239,8 @@ def build_graph(graphviz_graph, nodes, root_id, id_to_slices):
|
|
|
239
239
|
if node_id in id_to_slices:
|
|
240
240
|
slices = id_to_slices[node_id]
|
|
241
241
|
if not slices is None:
|
|
242
|
-
|
|
242
|
+
slices_iter = slices.reverse_iter() if config.horizontal else iter(slices)
|
|
243
|
+
for index in slices_iter:
|
|
243
244
|
child_id = id(children[index])
|
|
244
245
|
build_graph_depth_first(graphviz_graph, nodes, child_id, id_to_slices, nodes_at_depth, subgraphed_nodes, depth+1)
|
|
245
246
|
if not node.is_hidden_node():
|
|
@@ -268,6 +269,7 @@ def memory_to_nodes(data):
|
|
|
268
269
|
graph_attr=graphviz_graph_attr,
|
|
269
270
|
node_attr=graphviz_node_attr,
|
|
270
271
|
edge_attr=graphviz_edge_attr)
|
|
271
|
-
|
|
272
|
+
if config.horizontal:
|
|
273
|
+
graphviz_graph.attr(rankdir='LR')
|
|
272
274
|
build_graph(graphviz_graph, nodes, root_id, id_to_slices)
|
|
273
275
|
return graphviz_graph
|
|
@@ -60,6 +60,8 @@ class Node_Key_Value(Node_Base):
|
|
|
60
60
|
vertical = self.is_vertical(nodes, slices, id_to_slices)
|
|
61
61
|
if config.horizontal:
|
|
62
62
|
vertical = not vertical
|
|
63
|
+
if vertical:
|
|
64
|
+
html_table.reverse_rows()
|
|
63
65
|
if vertical:
|
|
64
66
|
self.fill_html_table_vertical(html_table, nodes, slices, id_to_slices)
|
|
65
67
|
else:
|
|
@@ -52,6 +52,8 @@ class Node_Linear(Node_Base):
|
|
|
52
52
|
vertical = self.is_vertical(nodes, slices, id_to_slices)
|
|
53
53
|
if config.horizontal:
|
|
54
54
|
vertical = not vertical # flip orientation if horizontal layout is set
|
|
55
|
+
if vertical:
|
|
56
|
+
html_table.reverse_rows()
|
|
55
57
|
if vertical:
|
|
56
58
|
self.fill_html_table_vertical(html_table, nodes, slices, id_to_slices)
|
|
57
59
|
else:
|
|
@@ -6,6 +6,7 @@ from memory_graph.node_base import Node_Base
|
|
|
6
6
|
from memory_graph.sequence import Sequence2D
|
|
7
7
|
from memory_graph.list_view import List_View
|
|
8
8
|
|
|
9
|
+
import memory_graph.config as config
|
|
9
10
|
import memory_graph.utils as utils
|
|
10
11
|
|
|
11
12
|
class Node_Table(Node_Base):
|
|
@@ -44,6 +45,10 @@ class Node_Table(Node_Base):
|
|
|
44
45
|
children_width = children_size[1]
|
|
45
46
|
col_slices = slices.get_col_slices()
|
|
46
47
|
|
|
48
|
+
# Better keep a table in normal order, I think
|
|
49
|
+
#if config.horizontal:
|
|
50
|
+
# html_table.reverse_rows()
|
|
51
|
+
|
|
47
52
|
# use column indices for header row
|
|
48
53
|
html_table.add_value(utils.unquoted_str(''), border=0)
|
|
49
54
|
for coli in col_slices.table_iter(children_width):
|
|
@@ -107,6 +107,9 @@ class Slices1D(Slices):
|
|
|
107
107
|
def __iter__(self):
|
|
108
108
|
return Slices_Iterator1D(self)
|
|
109
109
|
|
|
110
|
+
def reverse_iter(self):
|
|
111
|
+
return Slices_Iterator1D(self, reverse=True)
|
|
112
|
+
|
|
110
113
|
def has_index(self, index):
|
|
111
114
|
insert = bisect.bisect_right([s[0] for s in self.slices], index)
|
|
112
115
|
# print('insert:',insert,'index:',index,'slices:',self.slices)
|
|
@@ -150,6 +153,9 @@ class Slices2D(Slices):
|
|
|
150
153
|
def __iter__(self):
|
|
151
154
|
return Slices_Iterator2D(self)
|
|
152
155
|
|
|
156
|
+
def reverse_iter(self):
|
|
157
|
+
return Slices_Iterator2D(self, reverse=True)
|
|
158
|
+
|
|
153
159
|
def has_index(self, index):
|
|
154
160
|
i0, i1 = index
|
|
155
161
|
return self.row_slices.has_index(i0) and self.col_slices.has_index(i1)
|
|
@@ -17,9 +17,9 @@ class Slices_Iterator(ABC):
|
|
|
17
17
|
|
|
18
18
|
class Slices_Iterator1D(Slices_Iterator):
|
|
19
19
|
|
|
20
|
-
def __init__(self, slices1d):
|
|
20
|
+
def __init__(self, slices1d, reverse=False):
|
|
21
21
|
self.slices = slices1d
|
|
22
|
-
self.gen = self.generate()
|
|
22
|
+
self.gen = self.reverse_generate() if reverse else self.generate()
|
|
23
23
|
|
|
24
24
|
def __iter__(self):
|
|
25
25
|
return self
|
|
@@ -30,14 +30,20 @@ class Slices_Iterator1D(Slices_Iterator):
|
|
|
30
30
|
for i in range(slices[si][0], slices[si][1]):
|
|
31
31
|
yield i
|
|
32
32
|
|
|
33
|
+
def reverse_generate(self):
|
|
34
|
+
slices = self.slices.get_slices()
|
|
35
|
+
for si in range(len(slices)-1, -1, -1):
|
|
36
|
+
for i in range(slices[si][1]-1, slices[si][0]-1, -1):
|
|
37
|
+
yield i
|
|
38
|
+
|
|
33
39
|
def __next__(self):
|
|
34
40
|
return next(self.gen)
|
|
35
41
|
|
|
36
42
|
class Slices_Iterator2D(Slices_Iterator):
|
|
37
43
|
|
|
38
|
-
def __init__(self, slices2d):
|
|
44
|
+
def __init__(self, slices2d, reverse=False):
|
|
39
45
|
self.slices = slices2d
|
|
40
|
-
self.gen = self.generate()
|
|
46
|
+
self.gen = self.reverse_generate() if reverse else self.generate()
|
|
41
47
|
|
|
42
48
|
def __iter__(self):
|
|
43
49
|
return self
|
|
@@ -51,5 +57,14 @@ class Slices_Iterator2D(Slices_Iterator):
|
|
|
51
57
|
for col_i in range(col_slice[0], col_slice[1]):
|
|
52
58
|
yield (row_i, col_i)
|
|
53
59
|
|
|
60
|
+
def reverse_generate(self):
|
|
61
|
+
row_slices = self.slices.get_row_slices().get_slices()
|
|
62
|
+
col_slices = self.slices.get_col_slices().get_slices()
|
|
63
|
+
for row_slice in reversed(row_slices):
|
|
64
|
+
for row_i in range(row_slice[1]-1, row_slice[0]-1, -1):
|
|
65
|
+
for col_slice in reversed(col_slices):
|
|
66
|
+
for col_i in range(col_slice[1]-1, col_slice[0]-1, -1):
|
|
67
|
+
yield (row_i, col_i)
|
|
68
|
+
|
|
54
69
|
def __next__(self):
|
|
55
70
|
return next(self.gen)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memory_graph
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.85
|
|
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
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "memory_graph"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.85"
|
|
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"}
|
|
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
|