Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Sebastian Berg
On Mo, 2015-11-09 at 20:36 +0100, Ralf Gommers wrote: > > > On Mon, Nov 9, 2015 at 7:42 PM, Benjamin Root > wrote: > My personal rule for flexible inputs like that is that it > should be encouraged so long as it does not introduce > ambiguity. Furthermore, Allowing a scal

Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Irvin Probst
On 10/11/2015 09:19, Sebastian Berg wrote: since a scalar row (so just one row) is read and not a 2D array. I tend to say it should be an array-like argument and not a generalized sequence argument, just wanted to note that, since I am not sure what matlab does. Hi, By default Matlab reads ever

Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Sebastian Berg
On Di, 2015-11-10 at 10:24 +0100, Irvin Probst wrote: > On 10/11/2015 09:19, Sebastian Berg wrote: > > since a scalar row (so just one row) is read and not a 2D array. I tend > > to say it should be an array-like argument and not a generalized > > sequence argument, just wanted to note that, since

Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Irvin Probst
On 10/11/2015 14:17, Sebastian Berg wrote: Actually, it is the "sequence special case" type ;). (matlab does not have this, since matlab always returns 2-D I realized). As I said, if usecols is like indexing, the result should mimic: arr = np.loadtxt(f) arr = arr[usecols] in which case a 1-D a

Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Benjamin Root
Just pointing out np.loadtxt(..., ndmin=2) will always return a 2D array. Notice that without that option, the result is effectively squeezed. So if you don't specify that option, and you load up a CSV file with only one row, you will get a very differently shaped array than if you load up a CSV fi

Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Daπid
On 10 November 2015 at 16:07, Irvin Probst wrote: > I know this new behavior might break a lot of existing code as > usecol=(42,) used to return a 1-D array, but usecol=42, also > returns a 1-D array so the current behavior is not consistent imho. 42, is exactly the same as (42

Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Sebastian Berg
On Di, 2015-11-10 at 10:24 -0500, Benjamin Root wrote: > Just pointing out np.loadtxt(..., ndmin=2) will always return a 2D > array. Notice that without that option, the result is effectively > squeezed. So if you don't specify that option, and you load up a CSV > file with only one row, you will g

Re: [Numpy-discussion] loadtxt and usecols

2015-11-10 Thread Irvin Probst
On 10/11/2015 16:52, Daπid wrote: 42, is exactly the same as (42,) If you want a tuple of tuples, you have to do ((42,),), but then it raises: TypeError: list indices must be integers, not tuple. My bad, I wrote that too fast, please forget this. I think loadtxt should be a tool to r

Re: [Numpy-discussion] Question about structure arrays

2015-11-10 Thread aerojockey
Nathaniel Smith wrote > On Sat, Nov 7, 2015 at 1:18 PM, aerojockey < > pythondev1@ > > wrote: >> Hello, >> >> Recently I made some changes to a program I'm working on, and found that >> the >> changes made it four times slower than before. After some digging, I >> found >> out that one of the ne