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.
Files changed (41) hide show
  1. {memory_graph-0.3.77 → memory_graph-0.3.78}/PKG-INFO +10 -6
  2. {memory_graph-0.3.77 → memory_graph-0.3.78}/README.md +9 -5
  3. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/__init__.py +1 -1
  4. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/html_table.py +4 -2
  5. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/utils.py +5 -1
  6. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/PKG-INFO +10 -6
  7. {memory_graph-0.3.77 → memory_graph-0.3.78}/pyproject.toml +1 -1
  8. {memory_graph-0.3.77 → memory_graph-0.3.78}/LICENSE.txt +0 -0
  9. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/call_stack.py +0 -0
  10. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/config.py +0 -0
  11. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/config_default.py +0 -0
  12. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/config_helpers.py +0 -0
  13. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/extension_numpy.py +0 -0
  14. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/extension_pandas.py +0 -0
  15. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/extension_torch.py +0 -0
  16. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/list_view.py +0 -0
  17. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/memory_to_nodes.py +0 -0
  18. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_base.py +0 -0
  19. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_key_value.py +0 -0
  20. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_leaf.py +0 -0
  21. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_linear.py +0 -0
  22. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/node_table.py +0 -0
  23. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/sequence.py +0 -0
  24. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slicer.py +0 -0
  25. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slices.py +0 -0
  26. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slices_iterator.py +0 -0
  27. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/slices_table_iterator.py +0 -0
  28. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test.py +0 -0
  29. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_max_graph_depth.py +0 -0
  30. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_memory_graph.py +0 -0
  31. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_memory_to_nodes.py +0 -0
  32. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_sequence.py +0 -0
  33. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_slicer.py +0 -0
  34. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_slices.py +0 -0
  35. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph/test_slices_iterator.py +0 -0
  36. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/SOURCES.txt +0 -0
  37. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/dependency_links.txt +0 -0
  38. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/requires.txt +0 -0
  39. {memory_graph-0.3.77 → memory_graph-0.3.78}/memory_graph.egg-info/top_level.txt +0 -0
  40. {memory_graph-0.3.77 → memory_graph-0.3.78}/setup.cfg +0 -0
  41. {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.77
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
- Also note the difference between statement `b += [1]` that changes `b` and `a`, and statement `c = c + [300]` that first creates the new value `c + [300]` and assigns this value to `c` without effecting `b`. This shows that `x += y` is not the same as `x = x + y` for values of mutable type.
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.unquoted('') for i, v in enumerate(l.lst)]
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
  ![extension_numpy.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/extension_numpy.png)
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&continues=1).
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
  ![extension_pandas.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/extension_pandas.png)
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&continues=1).
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
- Also note the difference between statement `b += [1]` that changes `b` and `a`, and statement `c = c + [300]` that first creates the new value `c + [300]` and assigns this value to `c` without effecting `b`. This shows that `x += y` is not the same as `x = x + y` for values of mutable type.
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.unquoted('') for i, v in enumerate(l.lst)]
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
  ![extension_numpy.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/extension_numpy.png)
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&continues=1).
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
  ![extension_pandas.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/extension_pandas.png)
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&continues=1).
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()`:
@@ -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.77"
5
+ __version__ = "0.3.78"
6
6
  __author__ = 'Bas Terwijn'
7
7
 
8
8
  import memory_graph.memory_to_nodes as memory_to_nodes
@@ -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) or isinstance(value, utils.full_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}> {format_string(value, not rounded)} </TD>'
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' if it is a string. """
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.77
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
- Also note the difference between statement `b += [1]` that changes `b` and `a`, and statement `c = c + [300]` that first creates the new value `c + [300]` and assigns this value to `c` without effecting `b`. This shows that `x += y` is not the same as `x = x + y` for values of mutable type.
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.unquoted('') for i, v in enumerate(l.lst)]
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
  ![extension_numpy.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/extension_numpy.png)
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&continues=1).
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
  ![extension_pandas.png](https://raw.githubusercontent.com/bterwijn/memory_graph/main/images/extension_pandas.png)
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&continues=1).
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.77"
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