[Numpy-discussion] loadtxt example problem ?

Ryan May rmay31 at gmail.com
Mon May 4 16:10:25 EDT 2009


On Mon, May 4, 2009 at 3:06 PM, bruno Piguet <bruno.piguet at gmail.com> wrote:

> Hello,
>
>   I'm new to numpy, and considering using loadtxt() to read a data file.
>
>   As a starter, I tried the example of the doc page (
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html) :
>
>
> >>> from StringIO import StringIO   # StringIO behaves like a file object
> >>> c = StringIO("0 1\n2 3")
> >>> np.loadtxt(c)
> I didn't get the expectd answer, but :
>
> Traceback (moste recent call last):
>   File"(stdin)", line 1, in <module>
>   File "C:\Python25\lib\sire-packages\numpy\core\numeric.py", line 725, in loadtxt
>     X = array(X, dtype)
> ValueError: setting an array element with a sequence.
>
>
> I'm using verison 1.0.4 of numpy).
>
> I got the same problem on a Ms-Windows and a Linux Machine.
>
> I could run the example by adding a \n at the end of c :
> c = StringIO("0 1\n2 3\n")
>
>
> Is it the normal and expected behaviour ?
>
> Bruno.
>
>
It's a bug that's been fixed.  Numpy 1.0.4 is quite a bit out of date, so
I'd recommend updating to the latest (1.3).

Ryan


-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090504/ea54f5f1/attachment.html>


More information about the NumPy-Discussion mailing list