Bug when testing if a matrix is in SR
On sagemath 8.9, I find the behavior of SR
with matrix a bit strange.
sage: M = matrix([[0, -1], [1, 0]])
sage: print(SR(M)+M)
[[ 0 -1]
[ 1 0] -1]
[ 1 [ 0 -1]
[ 1 0]]
What is the use of coercing a matrix to the symbolic ring if it cannot be used as a matrix afterward?
These two lines of code also both raise an attribute error:
sage: SR(M) == M
sage: M in SR
AttributeError: 'ComplexIntervalField_class_with_category' object has no attribute 'complex_field'
By itself, it is not very relevant, but some element constructors (e.g. lie_algebra
) contain a line
if x in self.base_ring():
do something
which means SR
cannot be used as a base ring.
Is this a known bug?
A workaround would be to add a single line in SR.__contains__
to return false when x
is matrix (or maybe there are case when a matrix is considered in SR
, I don't know), but this would not solve the underlying issues.