sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.36k stars 462 forks source link

Error Creating Matrices of Differentials in SageMath 10.3+ #38583

Open smelczer opened 1 month ago

smelczer commented 1 month ago

Steps To Reproduce

In SageMath 10.3 or 10.4, run

W = DifferentialWeylAlgebra(PolynomialRing(SR,['t']))
D = list(W.differentials())
matrix(W,[D[0]])

or

W = DifferentialWeylAlgebra(PolynomialRing(SR,['t']))
D = list(W.differentials())
matrix(parent(D[0]),[D[0]])

Expected Behavior

The 1x1 matrix [dt] over the ring W

Actual Behavior

Throws error TypeError: unable to convert (0,) to a symbolic expression

Additional Information

Changing SR to another base ring gives an analogous error. The matrix constructor seems to try and put the differential in the base ring of W instead of W itself. Playing around in CoCalc, this error does not appear in SageMath 10.2 or earlier, but does appear in 10.3 and 10.4. Not sure if there were any changes to matrix (or DifferentialWeylAlgebra) in 10.3 that could be the cause.

Environment

- **OS**: Error occurs on CoCalc and my local mac installation
- **Sage Version**: Error appears in 10.3 and 10.4 on CoCalc (and not on 10.2-)

Checklist

fchapoton commented 1 month ago

note that this works

sage: M=MatrixSpace(W,1,1)
sage: M(D[0])
[dt]

and

sage: matrix(W,1,1,D[0])
[dt]
smelczer commented 3 weeks ago

It was pointed out to me that

W = DifferentialWeylAlgebra(PolynomialRing(SR,['t']))
D = list(W.differentials())
matrix(W,[[D[0]]])

works on all versions of Sage. It seems that up until 10.3 the matrix constructor could take a list and would make it a 1-row matrix (a vector). But 10.3+ requires its input to be a 2-d array (i.e., a list of lists) with 1 row. Not sure if this is intended behaviour with 10.3+, but if so then this issue should be closed.