Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Ryan May
Gary Ruben wrote: Try using astype. This works: values = array(wavearray.split()).astype(float) Why not use numpy.fromstring? fromstring(string, dtype=float, count=-1, sep='') Return a new 1d array initialized from the raw binary data in string. If count is positive, the new

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Adam Mercer
On 08/10/2007, Ryan May [EMAIL PROTECTED] 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 ...,

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Robert Kern
Adam Mercer wrote: On 08/10/2007, Ryan May [EMAIL PROTECTED] 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='') Use sep=' '. As the docstring says, if sep is empty, then

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Charles R Harris
On 10/8/07, Adam Mercer [EMAIL PROTECTED] wrote: On 08/10/2007, Ryan May [EMAIL PROTECTED] 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 You need to use

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Adam Mercer
On 08/10/2007, Robert Kern [EMAIL PROTECTED] wrote: Use sep=' '. As the docstring says, if sep is empty, then the string is interpreted as binary data. If it is not empty, then the string is interpreted as ASCII. Thanks, got it the wrong way round. That works now. Cheers Adam

[Numpy-discussion] Convert array type

2007-10-06 Thread Adam Mercer
Hi I am fairly new to using numpy and am running into a problem regarding the type of an array. The array in question is created using the following code: values = array(wavearray.split()) where wavearray is a string containing a series of floats separated by white space, it appears that the

Re: [Numpy-discussion] Convert array type

2007-10-06 Thread Gary Ruben
Try using astype. This works: values = array(wavearray.split()).astype(float) Gary R. Adam Mercer wrote: values = array(wavearray.split()) where wavearray is a string containing a series of floats separated by white space, it appears that the individual elements of the values array are

Re: [Numpy-discussion] Convert array type

2007-10-06 Thread Adam Mercer
On 07/10/2007, Gary Ruben [EMAIL PROTECTED] wrote: Try using astype. This works: values = array(wavearray.split()).astype(float) Thanks Gary, that does the trick. Cheers Adam ___ Numpy-discussion mailing list Numpy-discussion@scipy.org