Ticket #30402: matrix-load-save-bug-examples.txt

File matrix-load-save-bug-examples.txt, 9.4 KB (added by gh-penguian, 14 months ago)

Results of running test script with different versions of Sage

Line 
1~/test-matrix-save-load$ rm *.sobj
2~/test-matrix-save-load$ sage
3┌────────────────────────────────────────────────────────────────────┐
4│ SageMath version 8.6.rc0, Release Date: 2019-01-03                 │
5│ Using Python 2.7.15. Type "help()" for help.                       │
6└────────────────────────────────────────────────────────────────────┘
7┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
8┃ Warning: this is a prerelease version, and it may be unstable.     ┃
9┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
10sage: load('test-save.sage')
118.6.0
12pg_unpickle = unpickle_global('sage.matrix.matrix0', 'unpickle')
13pg_Matrix_integer_dense = unpickle_global('sage.matrix.matrix_integer_dense', 'Matrix_integer_dense')
14pg_unreduce = unpickle_global('sage.structure.unique_representation', 'unreduce')
15pg_MatrixSpace = unpickle_global('sage.matrix.matrix_space', 'MatrixSpace')
16pg_IntegerRing = unpickle_global('sage.rings.integer_ring', 'IntegerRing')
17pg = unpickle_instantiate(pg_IntegerRing, ())
18pg_unpickle(pg_Matrix_integer_dense, pg_unreduce(pg_MatrixSpace, (pg, 2r, 3r, False, pg_Matrix_integer_dense), {}), False, None, '-1 2 3 4 5 7', 0r)
19[-1  2  3]
20[ 4  5  7]
21pg_make_integer = unpickle_global('sage.rings.integer', 'make_integer')
22pg_unpickle = unpickle_global('sage.matrix.matrix0', 'unpickle')
23pg_Matrix_integer_dense = unpickle_global('sage.matrix.matrix_integer_dense', 'Matrix_integer_dense')
24pg_unreduce = unpickle_global('sage.structure.unique_representation', 'unreduce')
25pg_MatrixSpace = unpickle_global('sage.matrix.matrix_space', 'MatrixSpace')
26pg_IntegerRing = unpickle_global('sage.rings.integer_ring', 'IntegerRing')
27pg = unpickle_instantiate(pg_IntegerRing, ())
28{pg_make_integer('0'):'Hello', pg_make_integer('1'):pg_unpickle(pg_Matrix_integer_dense, pg_unreduce(pg_MatrixSpace, (pg, 2r, 3r, False, pg_Matrix_integer_dense), {}), False, None, '-1 2 3 4 5 7', 0r)}
29{0: 'Hello', 1: [-1  2  3]
30[ 4  5  7]}
31sage: quit
32Exiting Sage (CPU time 0m0.09s, Wall time 11m22.12s).
33~/test-matrix-save-load$ ls
34d.8.6.0.sobj  m.8.6.0.sobj  test-save.sage  tty.term
35
36~/test-matrix-save-load$ sage
37┌────────────────────────────────────────────────────────────────────┐
38│ SageMath version 9.1, Release Date: 2020-05-20                     │
39│ Create a "Sage Worksheet" file for the notebook interface.         │
40│ Enhanced for CoCalc.                                               │
41│ Using Python 3.7.3. Type "help()" for help.                        │
42└────────────────────────────────────────────────────────────────────┘
43sage: load('test-save.sage')
449.1.0
45pg_unpickle = unpickle_global('sage.matrix.matrix0', 'unpickle')
46pg_Matrix_integer_dense = unpickle_global('sage.matrix.matrix_integer_dense', 'Matrix_integer_dense')
47pg_unreduce = unpickle_global('sage.structure.unique_representation', 'unreduce')
48pg_MatrixSpace = unpickle_global('sage.matrix.matrix_space', 'MatrixSpace')
49pg_IntegerRing = unpickle_global('sage.rings.integer_ring', 'IntegerRing')
50pg = unpickle_instantiate(pg_IntegerRing, ())
51pg_encode = unpickle_global('_codecs', 'encode')
52pg_unpickle(pg_Matrix_integer_dense, pg_unreduce(pg_MatrixSpace, (pg, 2r, 3r, False, pg_Matrix_integer_dense), {}), False, None, pg_encode('-1 2 3 4 5 7', 'latin1'), 0r)
53[-1  2  3]
54[ 4  5  7]
55[-1  2  3]
56[ 4  5  7]
57pg_make_integer = unpickle_global('sage.rings.integer', 'make_integer')
58pg_unpickle = unpickle_global('sage.matrix.matrix0', 'unpickle')
59pg_Matrix_integer_dense = unpickle_global('sage.matrix.matrix_integer_dense', 'Matrix_integer_dense')
60pg_unreduce = unpickle_global('sage.structure.unique_representation', 'unreduce')
61pg_MatrixSpace = unpickle_global('sage.matrix.matrix_space', 'MatrixSpace')
62pg_IntegerRing = unpickle_global('sage.rings.integer_ring', 'IntegerRing')
63pg = unpickle_instantiate(pg_IntegerRing, ())
64pg_encode = unpickle_global('_codecs', 'encode')
65{pg_make_integer('0'):'Hello', pg_make_integer('1'):pg_unpickle(pg_Matrix_integer_dense, pg_unreduce(pg_MatrixSpace, (pg, 2r, 3r, False, pg_Matrix_integer_dense), {}), False, None, pg_encode('-1 2 3 4 5 7', 'latin1'), 0r)}
66{0: 'Hello', 1: [-1  2  3]
67[ 4  5  7]}
68{0: 'Hello', 1: [-1  2  3]
69[ 4  5  7]}
70sage: test_load('m.8.6.0.sobj')
71---------------------------------------------------------------------------
72RuntimeError                              Traceback (most recent call last)
73<ipython-input-2-6e4fbc5495e6> in <module>()
74----> 1 test_load('m.8.6.0.sobj')
75
76<string> in test_load(sobj_name)
77
78/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2900)()
79    156
80    157     ## Load file by absolute filename
81--> 158     with open(filename, 'rb') as fobj:
82    159         X = loads(fobj.read(), compress=compress, **kwargs)
83    160     try:
84
85/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2850)()
86    157     ## Load file by absolute filename
87    158     with open(filename, 'rb') as fobj:
88--> 159         X = loads(fobj.read(), compress=compress, **kwargs)
89    160     try:
90    161         X._default_filename = os.path.abspath(filename)
91
92/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.loads (build/cythonized/sage/misc/persist.c:7424)()
93   1042
94   1043     unpickler = SageUnpickler(io.BytesIO(s), **kwargs)
95-> 1044     return unpickler.load()
96   1045
97   1046
98
99/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.unpickle (build/cythonized/sage/matrix/matrix0.c:39715)()
100   5874     A._cache = cache
101   5875     if version >= 0:
102-> 5876         A._unpickle(data, version)
103   5877     else:
104   5878         A._unpickle_generic(data, version)
105
106/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense._unpickle (build/cythonized/sage/matrix/matrix_integer_dense.c:8221)()
107    540                 self._unpickle_matrix_2x2_version0(data)
108    541             else:
109--> 542                 raise RuntimeError("invalid pickle data")
110    543         else:
111    544             raise RuntimeError("unknown matrix version (=%s)"%version)
112
113RuntimeError: invalid pickle data
114sage: test_load_bytes('m.8.6.0.sobj')
115[-1  2  3]
116[ 4  5  7]
117sage: test_load('d.8.6.0.sobj')
118---------------------------------------------------------------------------
119RuntimeError                              Traceback (most recent call last)
120<ipython-input-4-e4e7116a2d02> in <module>()
121----> 1 test_load('d.8.6.0.sobj')
122
123<string> in test_load(sobj_name)
124
125/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2900)()
126    156
127    157     ## Load file by absolute filename
128--> 158     with open(filename, 'rb') as fobj:
129    159         X = loads(fobj.read(), compress=compress, **kwargs)
130    160     try:
131
132/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2850)()
133    157     ## Load file by absolute filename
134    158     with open(filename, 'rb') as fobj:
135--> 159         X = loads(fobj.read(), compress=compress, **kwargs)
136    160     try:
137    161         X._default_filename = os.path.abspath(filename)
138
139/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.loads (build/cythonized/sage/misc/persist.c:7424)()
140   1042
141   1043     unpickler = SageUnpickler(io.BytesIO(s), **kwargs)
142-> 1044     return unpickler.load()
143   1045
144   1046
145
146/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.unpickle (build/cythonized/sage/matrix/matrix0.c:39715)()
147   5874     A._cache = cache
148   5875     if version >= 0:
149-> 5876         A._unpickle(data, version)
150   5877     else:
151   5878         A._unpickle_generic(data, version)
152
153/ext/sage/sage-9.1/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense._unpickle (build/cythonized/sage/matrix/matrix_integer_dense.c:8221)()
154    540                 self._unpickle_matrix_2x2_version0(data)
155    541             else:
156--> 542                 raise RuntimeError("invalid pickle data")
157    543         else:
158    544             raise RuntimeError("unknown matrix version (=%s)"%version)
159
160RuntimeError: invalid pickle data
161sage: test_load_bytes('d.8.6.0.sobj')
162{0: b'Hello', 1: [-1  2  3]
163 [ 4  5  7]}
164sage: quit
165Exiting Sage (CPU time 0m0.87s, Wall time 2m1.11s).
166~/test-matrix-save-load$ ls
167d.8.6.0.sobj  d.9.1.0.sobj  m.8.6.0.sobj  m.9.1.0.sobj  test-save.sage  tty.term
168