1 | initial version |
One possibility is to
Here is how it would go.
The initial string:
sage: s = """
....: [ [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 0, 0, 1 ], [ 0, 0, 1, 0, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 0, 1, 1 ], [ 0, 0, 1, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 0, 0, 1 ], [ 0, 0, 1, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 1, 1, 1 ], [ 0, 0, 1, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 1 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 1, 1, 1 ], [ 0, 0, 1, 0, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ] ]
....: """
Turn it into a list:
sage: stats = sage_eval(s)
sage: stats
[[[[1, 1, 1, 1, 1],
[0, 1, 0, 0, 1],
[0, 0, 1, 0, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2],
[[[1, 1, 1, 1, 1],
[0, 1, 0, 1, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2],
[[[1, 1, 1, 1, 1],
[0, 1, 0, 0, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2],
[[[1, 1, 1, 1, 1],
[0, 1, 1, 1, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
1],
[[[1, 1, 1, 1, 1],
[0, 1, 1, 1, 1],
[0, 0, 1, 0, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2]]
Run the small loop to format as desired:
sage: for m, s in stats:
....: a = matrix(m)
....: i = a.parent().one()
....: d = (a - i).dict()
....: stat = list(d.keys()), a.ncols()
....: print(f"{stat} => {s}")
....:
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (2, 4), (3, 4)], 5) => 2
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)], 5) => 2
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (2, 3), (2, 4), (3, 4)], 5) => 2
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)], 5) => 1
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 4), (3, 4)], 5) => 2
2 | No.2 Revision |
One possibility is to
Here is how it would go.
The initial string:
sage: s = """
....: [ [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 0, 0, 1 ], [ 0, 0, 1, 0, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 0, 1, 1 ], [ 0, 0, 1, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 0, 0, 1 ], [ 0, 0, 1, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 1, 1, 1 ], [ 0, 0, 1, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 1 ],
....: [ [ [ 1, 1, 1, 1, 1 ], [ 0, 1, 1, 1, 1 ], [ 0, 0, 1, 0, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ], 2 ] ]
....: [[[[1, 1, 1, 1, 1], [0, 1, 0, 0, 1], [0, 0, 1, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]], 2],
[[[1, 1, 1, 1, 1], [0, 1, 0, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]], 2],
[[[1, 1, 1, 1, 1], [0, 1, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]], 2],
[[[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]], 1],
[[[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 0, 1, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]], 2]]
"""
Turn it into a list:
sage: stats = sage_eval(s)
sage: stats
[[[[1, 1, 1, 1, 1],
[0, 1, 0, 0, 1],
[0, 0, 1, 0, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2],
[[[1, 1, 1, 1, 1],
[0, 1, 0, 1, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2],
[[[1, 1, 1, 1, 1],
[0, 1, 0, 0, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2],
[[[1, 1, 1, 1, 1],
[0, 1, 1, 1, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
1],
[[[1, 1, 1, 1, 1],
[0, 1, 1, 1, 1],
[0, 0, 1, 0, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 1]],
2]]
Run the small loop to format as desired:
sage: for m, s in stats:
....: a = matrix(m)
....: i = a.parent().one()
....: d = (a - i).dict()
....: stat = list(d.keys()), a.ncols()
....: print(f"{stat} => {s}")
....:
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (2, 4), (3, 4)], 5) => 2
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)], 5) => 2
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (2, 3), (2, 4), (3, 4)], 5) => 2
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)], 5) => 1
([(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 4), (3, 4)], 5) => 2