[Numpy-discussion] numpy.fromstring() : error handling ?

Christopher Barker Chris.Barker@noaa....
Fri Aug 8 18:29:56 CDT 2008


oc-spam66 wrote:
> I am now disturbed by this result :
> 
>  > In [1]: import numpy
>  > In [2]: numpy.fromstring("abcd", dtype = float, sep = ' ')
>  > Out[2]: array([ 0.])
> 
> Shouldn't it raise an exception ValueError ? (because "abcd" is not a float)

I don't think so, but it shouldn't return a zero either.

That call should mean: scan this whitespace separated string for as many 
floating point numbers as it has. There are none, so it should return 
and empty array:

array([], dtype=float64)

fromstring() needs some work in a few other ways -- see my message a 
couple days ago.

Does anyone want to work on fromstring()? I'd like to , but my C skills 
are weak, so I could use some help.

-Chris





-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov


More information about the Numpy-discussion mailing list