Skip to content

Commit

Permalink
Simplify isinstance(R, Map) case
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Jan 30, 2024
1 parent 3b8ae11 commit fb1b108
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/sage/rings/polynomial/multi_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,17 @@ cdef class MPolynomial(CommutativePolynomial):
sage: (x+2*y).change_ring(GF(3))
x - y
::
sage: # needs sage.rings.finite_rings
sage: F.<a> = GF(7^2)
sage: R.<x,y> = F[]
sage: f = x^2 + a^2*y^2 + a*x + a^3*y
sage: g = f.change_ring(F.frobenius_endomorphism()); g
x^2 + (-a - 2)*y^2 + (-a + 1)*x + (2*a + 2)*y
sage: g.change_ring(F.frobenius_endomorphism()) == f
True
::
sage: # needs sage.rings.number_field
Expand Down Expand Up @@ -903,11 +914,8 @@ cdef class MPolynomial(CommutativePolynomial):
x
"""
if isinstance(R, Map):
if R.domain() == self.base_ring():
return self.map_coefficients(R)
return R(self)
else:
return self.parent().change_ring(R)(self.dict())
return self.map_coefficients(R)
return self.parent().change_ring(R)(self.dict())

def is_symmetric(self, group=None):
r"""
Expand Down

0 comments on commit fb1b108

Please sign in to comment.