I have a numpy array with 3 elements; from this array, I'd like to create a list where each element is in scientific notation, and not a string. This seems like it should be easy, but I'm having trouble with it. My current script is as follows:
import numpy as np
ary = np.array([2.124598e+00, 9.1542e+00, 1.049e+00])
ary = ary.astype(np.float)
ary = ary.tolist()
ary = ['%.9e' % x for x in ary]
print(ary)
print(type(ary))
Output is:
['2.124598000e+00', '9.154200000e+00', '1.049000000e+00']
<type 'list'>
How can I maintain scientific notation for each element, and have a non-string element type?
Edit: The goal here is to create an input file, so the formatting is done to match the formatting of a known input file. My ideal output is as follows:
[2.124598000e+00, 9.154200000e+00, 1.049000000e+00]
<type 'list'>
Removing ['%.9e' % x for x in ary]
gives me the following, without the scientific notation that I'm looking for:
[2.124598, 9.1542, 1.049]
<type 'list'>