-
-
Notifications
You must be signed in to change notification settings - Fork 661
Closed
Description
Dumps doesn't save immutability for matrices over GF(2).
Simple example:
z = zero_matrix(GF(2), 3)
z.set_immutable()
print(z.is_immutable())
zstr = z.dumps()
z2 = loads(zstr)
print(z2.is_immutable())
This affects saving matrices and in particular raises TypeError('mutable matrices are unhashable',)
when these matrices are used in hashed collections (set/dict etc):
z = zero_matrix(GF(2), 3)
z.set_immutable()
s = set()
s.add(z)
sstr = dumps(s)
s2 = loads(sstr)
Work Around for saving:
Saving lists of matrices works just fine, so if you need to save a set or dictionary, convert to/from a list on before/after save.
CC: @tscrim
Component: linear algebra
Keywords: immutable hashable matrix GF(2)
Issue created by migration from https://trac.sagemath.org/ticket/14681