load function

Humufr wrote:

    >> I agree with you but in the load function documentation I can
    >> read this:
    >>
    >> x,y = load('test.dat') # data in two columns

    > The documentation for load is correct. Consider

    > A=load('test.dat')

    > If 'test.dat' has 17 rows and 2 columns, A.shape will be
    > (17,2), "print A" will print an array with 17 rows and 2
    > columns, and so on. But

    > x,y=A

    > will not work, because tuple unpacking of numarray arrays
    > goes by rows, not by columns.

So the doc line with the tuple unpacking is *incorrect*, because tuple
unpacking will fail w/o the transpose. I modified the docs to read

    Example usage:

    X = load('test.dat') # data in two columns
    t = X[:,0]
    y = X[:,1]

    Alternatively, you can do

    t,y = transpose(load('test.dat')) # for two column data

Everybody happy with that?

JDH

Yes thank you John. It's perfect. Sorry for this but I pass so many times to understand the problem that I was thinking that another beginner will have the same problem than me.

Nicolas

John Hunter wrote:

···

"Stephen" == Stephen Walton <stephen.walton@...267...> writes:
           
   > Humufr wrote:
   >> I agree with you but in the load function documentation I can
   >> read this:
   >> >> x,y = load('test.dat') # data in two columns

   > The documentation for load is correct. Consider

   > A=load('test.dat')

   > If 'test.dat' has 17 rows and 2 columns, A.shape will be
   > (17,2), "print A" will print an array with 17 rows and 2
   > columns, and so on. But

   > x,y=A

   > will not work, because tuple unpacking of numarray arrays
   > goes by rows, not by columns.

So the doc line with the tuple unpacking is *incorrect*, because tuple
unpacking will fail w/o the transpose. I modified the docs to read

   Example usage:

   X = load('test.dat') # data in two columns
   t = X[:,0]
   y = X[:,1]

   Alternatively, you can do

   t,y = transpose(load('test.dat')) # for two column data

Everybody happy with that?

JDH

John Hunter wrote:

So the doc line with the tuple unpacking is *incorrect*, because tuple
unpacking will fail w/o the transpose.

Ouch. I completely missed the fact that Nicolas was commenting on the docstring, and generated a fair amount of noise as a result.

Thanks, John.