[Numpy-discussion] [SciPy-User] Saving Complex Numbers

David Warde-Farley dwf at cs.toronto.edu
Thu Jul 15 20:00:09 EDT 2010


(CCing NumPy-discussion where this really belongs)

On 2010-07-08, at 1:34 PM, cfrazer at uci.edu wrote:

> Need Complex numbers in the saved file.

Ack, this has come up several times according to list archives and no one's been able to provide a real answer.

It seems that there is nearly no formatting support for complex numbers in Python. for a single value, "{0.real:.18e}{0.imag:+.18e}".format(val) will get the job done, but because of the way numpy.savetxt creates its format string this isn't a trivial fix. 

Anyone else have ideas on how complex number format strings can be elegantly incorporated in savetxt?

David


More information about the NumPy-Discussion mailing list