Skip to content

Conversation

@jksuom
Copy link
Member

@jksuom jksuom commented Sep 25, 2017

The old polynomial ring currently prints in the same way as the
new one and its string representation only creates the new ring.

>>> A = ZZ.old_poly_ring(x)
>>> sstr(A)
'ZZ[x]'
>>> srepr(A)
'ZZ[x]'
>>> type(ZZ[x])
<class 'sympy.polys.domains.polynomialring.PolynomialRing'>
>>> type(A)
<class 'sympy.polys.domains.old_polynomialring.GlobalPolynomialRing'>

This commit defines a representation string that can be used to
construct the old polynomial ring.

>>> srepr(A)
"GlobalPolynomialRing(ZZ, Symbol('x'))"

With fraction fields, there is another issue. The printed string
of type QQ(x) cannot be used at all to create a SymPy object.
Therefore a new representation is defined.

>>> K = QQ.frac_field(x)
>>> sstr(K)
'QQ(x)'
>>> srepr(K)
"FractionField(FracField((Symbol('x'),), QQ, lex))"

The old polynomial ring currently prints in the same way as the
new one and its string representation only creates the new ring.

>>> A = ZZ.old_poly_ring(x)
>>> sstr(A)
'ZZ[x]'
>>> srepr(A)
'ZZ[x]'
>>> type(ZZ[x])
<class 'sympy.polys.domains.polynomialring.PolynomialRing'>
>>> type(A)
<class 'sympy.polys.domains.old_polynomialring.GlobalPolynomialRing'>

This commit defines a representation string that can be used to
construct the old polynomial ring.

>>> srepr(A)
"GlobalPolynomialRing(ZZ, Symbol('x'))"

With fraction fields, there is another issue. The printed string
of type QQ(x) cannot be used at all to create a SymPy object.
Therefore a new representation is defined.

>>> K = QQ.frac_field(x)
>>> sstr(K)
'QQ(x)'
>>> srepr(K)
"FractionField(FracField((Symbol('x'),), QQ, lex))"
@smichr
Copy link
Member

smichr commented Sep 25, 2017

+1

@gxyd
Copy link
Contributor

gxyd commented Sep 26, 2017

Looks good. Merging, thanks @jksuom :)

@gxyd gxyd merged commit edc897b into sympy:master Sep 26, 2017
@jksuom jksuom deleted the srepr-of-polynomialring branch September 26, 2017 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants