memory-graph 0.3.77__tar.gz → 0.3.78__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.77 → memory_graph-0.3.78}/PKG-INFO +10 -6
- {memory_graph-0.3.77 → memory_graph-0.3.78}/README.md +9 -5
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/__init__.py +1 -1
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/html_table.py +4 -2
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/utils.py +5 -1
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/PKG-INFO +10 -6
- {memory_graph-0.3.77 → memory_graph-0.3.78}/pyproject.toml +1 -1
- {memory_graph-0.3.77 → memory_graph-0.3.78}/LICENSE.txt +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/call_stack.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/config.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/config_default.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/config_helpers.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/extension_numpy.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/extension_pandas.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/extension_torch.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/list_view.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/memory_to_nodes.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_base.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_key_value.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_leaf.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_linear.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_table.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/sequence.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slicer.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slices.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slices_iterator.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slices_table_iterator.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_max_graph_depth.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_memory_graph.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_memory_to_nodes.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_sequence.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_slicer.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_slices.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_slices_iterator.py +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/SOURCES.txt +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/dependency_links.txt +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/requires.txt +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/top_level.txt +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/setup.cfg +0 -0
- {memory_graph-0.3.77 → memory_graph-0.3.78}/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.78
|
|
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
|
|
@@ -102,7 +102,7 @@ a graph showing `a` and `b` share the list
|
|
|
102
102
|
|
|
103
103
|
</td></tr></table>
|
|
104
104
|
|
|
105
|
-
The fact that `a` and `b` share the list can not be verified by printing the lists. It can be verified by comparing the identity of both variables using the `id()` function or by using the `is` comparison operator as shown in the program output below, but this quickly becomes impractical for larger programs.
|
|
105
|
+
The fact that `a` and `b` share the list can **not** be verified by printing the lists. It can be verified by comparing the identity of both variables using the `id()` function or by using the `is` comparison operator as shown in the program output below, but this quickly becomes impractical for larger programs.
|
|
106
106
|
```{verbatim}
|
|
107
107
|
a: 4, 3, 2, 1
|
|
108
108
|
b: 4, 3, 2, 1
|
|
@@ -275,7 +275,11 @@ Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#codeurl=ht
|
|
|
275
275
|
## Name Rebinding ##
|
|
276
276
|
When `a` and `b` share a mutable value, then changing the value of `b` changes the value of `a` and vice versa. However, reassigning `b` does not change `a`. When you reassign `b`, you only **rebind** the name `b` to another value without affecting any other variable.
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
In the example below, also note the difference between expressions:
|
|
279
|
+
- `b += [300]`: that changes both `b` and `a`
|
|
280
|
+
- `c = c + [600]`: that first creates a new value `c + [600]` and then assigns this new value to `c` without affecting `b`
|
|
281
|
+
|
|
282
|
+
This shows that `x += y` is not the same as `x = x + y` for a value `x` of mutable type.
|
|
279
283
|
|
|
280
284
|
```python
|
|
281
285
|
import memory_graph as mg
|
|
@@ -1245,7 +1249,7 @@ Arguably the visualization is then more clear when we show a List_View object as
|
|
|
1245
1249
|
|
|
1246
1250
|
```python
|
|
1247
1251
|
mg.config.type_to_node[List_View] = (lambda l: mg.Node_Linear(l,
|
|
1248
|
-
[v if l.begin <= i < l.end else mg.
|
|
1252
|
+
[v if l.begin <= i < l.end else mg.unquoted_str('') for i, v in enumerate(l.lst)]
|
|
1249
1253
|
if hasattr(l, 'end') else [])
|
|
1250
1254
|
)
|
|
1251
1255
|
```
|
|
@@ -1384,7 +1388,7 @@ mg.show(locals())
|
|
|
1384
1388
|
```
|
|
1385
1389
|

|
|
1386
1390
|
|
|
1387
|
-
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=numpy&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_numpy.py&
|
|
1391
|
+
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=numpy&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_numpy.py&play).
|
|
1388
1392
|
|
|
1389
1393
|
## Pandas ##
|
|
1390
1394
|
For pandas types `Series` and `DataFrame`, use `mg.extend_pandas()`:
|
|
@@ -1405,7 +1409,7 @@ mg.show(locals())
|
|
|
1405
1409
|
```
|
|
1406
1410
|

|
|
1407
1411
|
|
|
1408
|
-
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=pandas&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_pandas.py&
|
|
1412
|
+
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=pandas&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_pandas.py&play).
|
|
1409
1413
|
|
|
1410
1414
|
## PyTorch ##
|
|
1411
1415
|
For torch type `tensor`, use `mg.extend_torch()`:
|
|
@@ -82,7 +82,7 @@ a graph showing `a` and `b` share the list
|
|
|
82
82
|
|
|
83
83
|
</td></tr></table>
|
|
84
84
|
|
|
85
|
-
The fact that `a` and `b` share the list can not be verified by printing the lists. It can be verified by comparing the identity of both variables using the `id()` function or by using the `is` comparison operator as shown in the program output below, but this quickly becomes impractical for larger programs.
|
|
85
|
+
The fact that `a` and `b` share the list can **not** be verified by printing the lists. It can be verified by comparing the identity of both variables using the `id()` function or by using the `is` comparison operator as shown in the program output below, but this quickly becomes impractical for larger programs.
|
|
86
86
|
```{verbatim}
|
|
87
87
|
a: 4, 3, 2, 1
|
|
88
88
|
b: 4, 3, 2, 1
|
|
@@ -255,7 +255,11 @@ Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#codeurl=ht
|
|
|
255
255
|
## Name Rebinding ##
|
|
256
256
|
When `a` and `b` share a mutable value, then changing the value of `b` changes the value of `a` and vice versa. However, reassigning `b` does not change `a`. When you reassign `b`, you only **rebind** the name `b` to another value without affecting any other variable.
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
In the example below, also note the difference between expressions:
|
|
259
|
+
- `b += [300]`: that changes both `b` and `a`
|
|
260
|
+
- `c = c + [600]`: that first creates a new value `c + [600]` and then assigns this new value to `c` without affecting `b`
|
|
261
|
+
|
|
262
|
+
This shows that `x += y` is not the same as `x = x + y` for a value `x` of mutable type.
|
|
259
263
|
|
|
260
264
|
```python
|
|
261
265
|
import memory_graph as mg
|
|
@@ -1225,7 +1229,7 @@ Arguably the visualization is then more clear when we show a List_View object as
|
|
|
1225
1229
|
|
|
1226
1230
|
```python
|
|
1227
1231
|
mg.config.type_to_node[List_View] = (lambda l: mg.Node_Linear(l,
|
|
1228
|
-
[v if l.begin <= i < l.end else mg.
|
|
1232
|
+
[v if l.begin <= i < l.end else mg.unquoted_str('') for i, v in enumerate(l.lst)]
|
|
1229
1233
|
if hasattr(l, 'end') else [])
|
|
1230
1234
|
)
|
|
1231
1235
|
```
|
|
@@ -1364,7 +1368,7 @@ mg.show(locals())
|
|
|
1364
1368
|
```
|
|
1365
1369
|

|
|
1366
1370
|
|
|
1367
|
-
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=numpy&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_numpy.py&
|
|
1371
|
+
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=numpy&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_numpy.py&play).
|
|
1368
1372
|
|
|
1369
1373
|
## Pandas ##
|
|
1370
1374
|
For pandas types `Series` and `DataFrame`, use `mg.extend_pandas()`:
|
|
@@ -1385,7 +1389,7 @@ mg.show(locals())
|
|
|
1385
1389
|
```
|
|
1386
1390
|

|
|
1387
1391
|
|
|
1388
|
-
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=pandas&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_pandas.py&
|
|
1392
|
+
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=pandas&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_pandas.py&play).
|
|
1389
1393
|
|
|
1390
1394
|
## PyTorch ##
|
|
1391
1395
|
For torch type `tensor`, use `mg.extend_torch()`:
|
|
@@ -15,8 +15,10 @@ def format_string(value, quote_str):
|
|
|
15
15
|
""" Helper function to format 'value' to be shown in the graph. We escape html characters and convert newlines to <BR/> tags. """
|
|
16
16
|
to_string = config_helpers.get_to_string(value)
|
|
17
17
|
s = to_string(value)
|
|
18
|
-
if quote_str and isinstance(value, str
|
|
18
|
+
if quote_str and isinstance(value, (str, utils.full_str)):
|
|
19
19
|
s = utils.quote_string(s)
|
|
20
|
+
if not isinstance(value, utils.html_str): # <IMG> can't have padding in Graphviz
|
|
21
|
+
s = utils.pad_string(s)
|
|
20
22
|
return s
|
|
21
23
|
|
|
22
24
|
class HTML_Table:
|
|
@@ -77,7 +79,7 @@ class HTML_Table:
|
|
|
77
79
|
""" Helper function to add 'value' to the table. """
|
|
78
80
|
self.check_add_new_line()
|
|
79
81
|
r = ' STYLE="ROUNDED"' if rounded else ''
|
|
80
|
-
self.html += f'<TD BORDER="{border}"{r}>
|
|
82
|
+
self.html += f'<TD BORDER="{border}"{r}>{format_string(value, not rounded)}</TD>'
|
|
81
83
|
self.is_empty = False
|
|
82
84
|
self.col_count += 1
|
|
83
85
|
|
|
@@ -45,9 +45,13 @@ def prep_str(s):
|
|
|
45
45
|
return newlines_to_br(html_escape(limit_string(s)))
|
|
46
46
|
|
|
47
47
|
def quote_string(s):
|
|
48
|
-
""" Quote 's'
|
|
48
|
+
""" Quote string 's'. """
|
|
49
49
|
return "'" + s + "'"
|
|
50
50
|
|
|
51
|
+
def pad_string(s):
|
|
52
|
+
""" Pad string 's'. """
|
|
53
|
+
return " " + s + " "
|
|
54
|
+
|
|
51
55
|
def exception_to_string(e):
|
|
52
56
|
""" Helper function to convert the traceback of an exception to a string. """
|
|
53
57
|
return ''.join(traceback.format_exception(type(e), e, e.__traceback__)).strip()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memory_graph
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.78
|
|
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
|
|
@@ -102,7 +102,7 @@ a graph showing `a` and `b` share the list
|
|
|
102
102
|
|
|
103
103
|
</td></tr></table>
|
|
104
104
|
|
|
105
|
-
The fact that `a` and `b` share the list can not be verified by printing the lists. It can be verified by comparing the identity of both variables using the `id()` function or by using the `is` comparison operator as shown in the program output below, but this quickly becomes impractical for larger programs.
|
|
105
|
+
The fact that `a` and `b` share the list can **not** be verified by printing the lists. It can be verified by comparing the identity of both variables using the `id()` function or by using the `is` comparison operator as shown in the program output below, but this quickly becomes impractical for larger programs.
|
|
106
106
|
```{verbatim}
|
|
107
107
|
a: 4, 3, 2, 1
|
|
108
108
|
b: 4, 3, 2, 1
|
|
@@ -275,7 +275,11 @@ Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#codeurl=ht
|
|
|
275
275
|
## Name Rebinding ##
|
|
276
276
|
When `a` and `b` share a mutable value, then changing the value of `b` changes the value of `a` and vice versa. However, reassigning `b` does not change `a`. When you reassign `b`, you only **rebind** the name `b` to another value without affecting any other variable.
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
In the example below, also note the difference between expressions:
|
|
279
|
+
- `b += [300]`: that changes both `b` and `a`
|
|
280
|
+
- `c = c + [600]`: that first creates a new value `c + [600]` and then assigns this new value to `c` without affecting `b`
|
|
281
|
+
|
|
282
|
+
This shows that `x += y` is not the same as `x = x + y` for a value `x` of mutable type.
|
|
279
283
|
|
|
280
284
|
```python
|
|
281
285
|
import memory_graph as mg
|
|
@@ -1245,7 +1249,7 @@ Arguably the visualization is then more clear when we show a List_View object as
|
|
|
1245
1249
|
|
|
1246
1250
|
```python
|
|
1247
1251
|
mg.config.type_to_node[List_View] = (lambda l: mg.Node_Linear(l,
|
|
1248
|
-
[v if l.begin <= i < l.end else mg.
|
|
1252
|
+
[v if l.begin <= i < l.end else mg.unquoted_str('') for i, v in enumerate(l.lst)]
|
|
1249
1253
|
if hasattr(l, 'end') else [])
|
|
1250
1254
|
)
|
|
1251
1255
|
```
|
|
@@ -1384,7 +1388,7 @@ mg.show(locals())
|
|
|
1384
1388
|
```
|
|
1385
1389
|

|
|
1386
1390
|
|
|
1387
|
-
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=numpy&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_numpy.py&
|
|
1391
|
+
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=numpy&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_numpy.py&play).
|
|
1388
1392
|
|
|
1389
1393
|
## Pandas ##
|
|
1390
1394
|
For pandas types `Series` and `DataFrame`, use `mg.extend_pandas()`:
|
|
@@ -1405,7 +1409,7 @@ mg.show(locals())
|
|
|
1405
1409
|
```
|
|
1406
1410
|

|
|
1407
1411
|
|
|
1408
|
-
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=pandas&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_pandas.py&
|
|
1412
|
+
Or see it in the [Memory Grah Web Debugger](https://memory-graph.com/#micropip=pandas&codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/mg_pandas.py&play).
|
|
1409
1413
|
|
|
1410
1414
|
## PyTorch ##
|
|
1411
1415
|
For torch type `tensor`, use `mg.extend_torch()`:
|
|
@@ -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.78"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|