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

Commit

Permalink
Allow type complex input in ComplexNumber()
Browse files Browse the repository at this point in the history
  • Loading branch information
epilys committed Mar 15, 2017
1 parent 457b950 commit c1995f1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sage/rings/complex_number.pyx
Expand Up @@ -2481,11 +2481,18 @@ def create_ComplexNumber(s_real, s_imag=None, int pad=0, min_prec=53):
False
sage: sage.rings.complex_number.create_ComplexNumber(0,s).imag()-1 == 0
False
sage: sage.rings.complex_number.create_ComplexNumber(complex('13.8+6.2j')) == CC(complex('13.8+6.2j'))
True
"""
if s_imag is None:
s_imag = 0

if isinstance(s_real, complex):
from .complex_field import ComplexField
C = ComplexField(prec=min_prec)
return C(s_real.real, s_real.imag)

if not isinstance(s_real, str):
s_real = str(s_real).strip()
if not isinstance(s_imag, str):
Expand Down

0 comments on commit c1995f1

Please sign in to comment.