[Numpy-discussion] loadtxt ndmin option

Benjamin Root ben.root at ou.edu
Tue May 31 11:45:48 EDT 2011


On Tue, May 31, 2011 at 10:33 AM, Bruce Southey <bsouthey at gmail.com> wrote:

> On 05/31/2011 10:18 AM, Pierre GM wrote:
> > On May 31, 2011, at 4:53 PM, Derek Homeier wrote:
> >
> >> Hi Chris,
> >>
> >> On 31 May 2011, at 13:56, cgraves wrote:
> >>
> >>> I've downloaded the latest numpy (1.6.0) and loadtxt has the ndmin
> >>> option,
> >>> however neither genfromtxt nor recfromtxt, which use loadtxt, have it.
> >>> Should they have inherited the option? Who can make it happen?
> >> you are mistaken, genfromtxt is not using loadtxt (and could not
> >> possibly, since it has the more complex parser to handle missing
> >> data); thus ndmin could not be inherited automatically.
> >> It certainly would make sense to provide the same functionality for
> >> genfromtxt (which should then be inherited by [nd,ma,rec]fromtxt), so
> >> I'd go ahead and file a feature (enhancement) request. I can't promise
> >> I can take care of it myself, as I am less familiar with genfromtxt,
> >> but I'd certainly have a look at it.
> > Oh, that shouldn't be too difficult: 'ndmin' tells whether the array must
> be squeezed before being returned, right ? You can add some test at the very
> end of genfromtxt to check what to do with the output (whether to squeeze it
> or not, whether to transpose it or not)... If you don't mind doing it, I'd
> be quite grateful (I don't have time to work on numpy these days, much to my
> regret). Don't forget to change the user manual as well...
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> (Different function so different ticket.)
>
> Sure you can change the end of the code but that may hide various
> problem. Unlike loadtxt, genfromtxt has a lot of flexibility especially
> handling missing values and using converter functions. So I think that
> some examples must be provided that can not be handled by providing a
> suitable converter or that require multiple assumptions about input file
> (such as having more than one delimiter).
>
> Bruce
>

At this point, I wonder if it might be smarter to create a .atleast_Nd()
function and use that everywhere it is needed.  Having similar logic
tailored for each loading function might be a little dangerous if bug fixes
are made to one, but not the others.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110531/3452c93e/attachment.html>


More information about the NumPy-Discussion mailing list