Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
#18036 minor code adaptations in rings/
Browse files Browse the repository at this point in the history
  • Loading branch information
mezzarobba committed Nov 8, 2020
1 parent 11be379 commit 8125051
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -863,14 +863,9 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
real, imag = z
elif isinstance(z, complex):
real, imag = z.real, z.imag
elif isinstance(z, sage.symbolic.expression.Expression):
zz = sage.rings.complex_mpfr.ComplexField(self._parent.prec())(z)
self._set(zz)
return
elif type(z) is gmpy2.mpc:
mpc_set(self.value, (<gmpy2.mpc>z).c, rnd)
return
# then, no imaginary part
elif type(z) is gmpy2.mpfr:
mpc_set_fr(self.value, (<gmpy2.mpfr>z).f, rnd)
return
Expand All @@ -891,8 +886,13 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
mpc_set_si(self.value, z, rnd)
return
else:
real = z
imag = 0
C = sage.rings.complex_mpfr.ComplexField(self._parent.prec())
if C.has_coerce_map_from(z.parent()) or isinstance(z, sage.symbolic.expression.Expression):
self._set(C(z))
return
else:
real = z
imag = 0
else:
real = z
imag = y
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/polynomial_rational_flint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ cdef class Polynomial_rational_flint(Polynomial):
else:
try:
len = <unsigned long> (degree + 1)
except ValueError:
except (TypeError, ValueError):
raise ValueError('degree must be convertible to long')

res = self._new()
Expand Down

0 comments on commit 8125051

Please sign in to comment.