<div class="gmail_quote">On Wed, May 4, 2011 at 7:54 PM, Derek Homeier <span dir="ltr"><<a href="mailto:derek@astro.physik.uni-goettingen.de">derek@astro.physik.uni-goettingen.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 05.05.2011, at 2:40AM, Paul Anton Letnes wrote:<br>
<br>
> But: Isn't the numpy.atleast_2d and numpy.atleast_1d functions written for this? Shouldn't we reuse them? Perhaps it's overkill, and perhaps it will reintroduce the 'transposed' problem?<br>
<br>
</div>Yes, good point, one could replace the<br>
X.shape = (X.size, ) with X = np.atleast_1d(X),<br>
but for the ndmin=2 case, we'd need to replace<br>
X.shape = (X.size, 1) with X = np.atleast_2d(X).T -<br>
not sure which solution is more efficient in terms of memory access etc...<br>
<br>
Cheers,<br>
<font color="#888888">                                                Derek<br>
</font><div><div></div><div class="h5"><br>
</div></div></blockquote><div><br>I can confirm that the current behavior is not sufficient for all of the original corner cases that ndmin was supposed to address.  Keep in mind that np.loadtxt takes a one-column data file and a one-row data file down to the same shape.  I don't see how the current code is able to produce the correct array shape when ndmin=2.  Do we have some sort of counter in loadtxt for counting the number of rows and columns read?  Could we use those to help guide the ndmin=2 case?<br>

<br>I think that using atleast_1d(X) might be a bit overkill, but it would be very clear as to the code's intent.  I don't think we have to worry about memory usage if we limit its use to only situations where ndmin is greater than the number of dimensions of the array.  In those cases, the array is either an empty result, a scalar value (in which memory access is trivial), or 1-d (in which a transpose is cheap).<br>

<br>Ben Root<br></div></div>