[Numpy-discussion] Convert array type

Adam Mercer ramercer@gmail....
Mon Oct 8 14:36:39 CDT 2007


On 08/10/2007, Ryan May <rmay@ou.edu> wrote:

> Why not use numpy.fromstring?

because that results in the array being filled with gibberish

values = numpy.fromstring(wavearray, dtype=float, count=-1, sep='')
print values

gives:

[  1.39804329e-076   1.30354290e-076   1.18295070e-076 ...,
   5.45168074e-067   2.11101912e-052   6.58519056e-260]

where using

values = array(wavearray.split()).astype(float)
print values

results in the correct

[  0.00000000e+00   0.00000000e+00   0.00000000e+00 ...,
   4.22233200e-23   3.86799900e-23   3.48452000e-23]

Cheers

Adam


More information about the Numpy-discussion mailing list