[Numpy-discussion] indexing problem

Ryan Krauss ryanlists at gmail.com
Mon Feb 13 09:45:04 EST 2006


I am having a problem with indexing an array and not getting the
expected scalar behavior for complex128scalar:

In [44]: c
Out[44]:
array([  3.31781200e+06,   2.20157529e+13,   1.46088259e+20,
         9.69386754e+26,   6.43248601e+33,   4.26835585e+40,
         2.83232045e+47,   1.87942136e+54,   1.24711335e+61,
         8.27537526e+67])

In [45]: s=c[-1]*1.0j

In [46]: type(s)
Out[46]: <type 'complex128scalar'>

In [47]: s**2
Out[47]: (-6.848183561893313e+135+8.3863291020365108e+119j)

In [48]: s=8.27537526e+67*1.0j

In [49]: type(s)
Out[49]: <type 'complex'>

In [50]: s**2
Out[50]: (-6.8481835693820068e+135+0j)

Why does result 47 have a non-zero imaginary part?

Ryan




More information about the NumPy-Discussion mailing list