sagemath / sage

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

sage_input for multivariate polynomials #25723

Open AndrewMathas opened 6 years ago

AndrewMathas commented 6 years ago

Multivariate polynomials do not currently have a _sage_input_ method. This ticket rectifies this:

sage: sage_input(ZZ['u','q'])
ZZ['u,q']

Component: basic arithmetic

Keywords: Multivariate polynomials, days94

Author: Andrew Mathas

Branch/Commit: u/andrew.mathas/sage_input_for_multivariate_polynomials @ a309ff6

Reviewer: Thierry Monteil

Issue created by migration from https://trac.sagemath.org/ticket/25723

AndrewMathas commented 6 years ago

Branch: u/andrew.mathas/sage_input_for_multivariate_polynomials

AndrewMathas commented 6 years ago

Changed keywords from none to Multivariate polynomials

AndrewMathas commented 6 years ago

Description changed:

--- 
+++ 
@@ -1 +1,6 @@
+Multivariate polynomials do not currently have a `_sage_input_` method. This ticket rectifies this:

+```
+sage: sage_input(ZZ['u','q'])
+ZZ['u,q']
+```
AndrewMathas commented 6 years ago

Author: Andrew Mathas

AndrewMathas commented 6 years ago

Commit: a309ff6

edd8e884-f507-429a-b577-5d554626c0fe commented 6 years ago

Reviewer: Thierry Monteil

edd8e884-f507-429a-b577-5d554626c0fe commented 6 years ago
comment:3

The current implementation does not handle the sparsity nor the monomial order of the polynomial ring:

sage: R.<x,y> = PolynomialRing(QQ, order='neglex', sparse=True)
sage: R
Multivariate Polynomial Ring in x, y over Rational Field

sage: sage_input(R)
QQ['x,y']

sage: sage_eval(sage_input(R)) is R
False

sage: sage_input(R, verify=True)
AssertionError: Expected Multivariate Polynomial Ring in x, y over Rational Field == Multivariate Polynomial Ring in x, y over Rational Field

You need to check all those cases with the verify=True option.

See also #22565 and #25762 for similar issues.

edd8e884-f507-429a-b577-5d554626c0fe commented 6 years ago

Changed keywords from Multivariate polynomials to Multivariate polynomials, days94

AndrewMathas commented 6 years ago
comment:4

Replying to @sagetrac-tmonteil:

The current implementation does not handle the sparsity nor the monomial order of the polynomial ring:

sage: R.<x,y> = PolynomialRing(QQ, order='neglex', sparse=True)
sage: R
Multivariate Polynomial Ring in x, y over Rational Field

sage: sage_input(R)
QQ['x,y']

sage: sage_eval(sage_input(R)) is R
False

sage: sage_input(R, verify=True)
AssertionError: Expected Multivariate Polynomial Ring in x, y over Rational Field == Multivariate Polynomial Ring in x, y over Rational Field

You need to check all those cases with the verify=True option.

See also #22565 and #25762 for similar issues.

I agree that the (term) order should be taken into account but looking at both the documentation and the code sparse is not an option for multivariate polynomial rings. (I agree that it is an option for polynomial rings.) Am I missing something?