Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imag(complex(0,1)) gives TypeError (easy) #5420

Closed
jasongrout opened this issue Mar 2, 2009 · 2 comments
Closed

imag(complex(0,1)) gives TypeError (easy) #5420

jasongrout opened this issue Mar 2, 2009 · 2 comments

Comments

@jasongrout
Copy link
Member

sage: imag(complex(0,1))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/grout/.sage/temp/good/9936/_home_grout__sage_init_sage_0.py in <module>()

/home/grout/sage/local/lib/python2.5/site-packages/sage/misc/functional.pyc in imag(x)
    376     Return the imaginary part of x.
    377     """
--> 378     try: return x.imag()
    379     except AttributeError: return CDF(x).imag()
    380 

TypeError: 'float' object is not callable

This is because complex(0,1).imag is a number, not a function, so trying to call that number gives the error. As Robert Bradshaw said on the mailing list, Sage's imag() should really know about python complex numbers.

Component: algebra

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

@jasongrout jasongrout added this to the sage-4.1.1 milestone Mar 2, 2009
@jasongrout jasongrout self-assigned this Mar 13, 2009
@aghitza
Copy link

aghitza commented Jun 2, 2009

comment:2

This looks fine in sage-4.0:

----------------------------------------------------------------------
| Sage Version 4.0, Release Date: 2009-05-29                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: imag(complex(0,1))
1.00000000000000

@aghitza aghitza changed the title imag(complex(0,1)) gives TypeError (easy) [already fixed?] imag(complex(0,1)) gives TypeError (easy) Jun 2, 2009
@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jul 26, 2009

comment:3

This also looks OK with Sage 4.1:

----------------------------------------------------------------------
| Sage Version 4.1, Release Date: 2009-07-09                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: imag(complex(0,1))
1.00000000000000

So I'm closing this ticket as fixed.

@sagetrac-mvngu sagetrac-mvngu mannequin changed the title [already fixed?] imag(complex(0,1)) gives TypeError (easy) imag(complex(0,1)) gives TypeError (easy) Jul 26, 2009
@sagetrac-mvngu sagetrac-mvngu mannequin closed this as completed Jul 26, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants