[Numpy-discussion] why numarray.inputarray?
jmiller at stsci.edu
Wed Feb 11 10:58:35 CST 2004
On Tue, 2004-02-10 at 16:17, Colin J. Williams wrote:
> Todd Miller wrote:
> >On Tue, 2004-02-10 at 09:31, Colin J. Williams wrote:
> >>Tim Hochberg wrote:
> >>>I just noticed that the name asarray is considered obsolete and is to
> >>>be replaced with inputarray. Why is that? The name asarray has a
> >>>pretty clear connection with it's behaviour (return it's argument as
> >>>an array), while I can come up with no such connection for inputarray.
> >>>The best I can come up with is that it's often used on the inputs of
> >>>functions to coerce them to arrays, but that seems a pretty tenuous
> >>>connection. Is there a better reason? Am I just being obtuse?
> >>I agree that the term asarray better describes the functionality.
> >>One possible use would be to convert an instance of a sub-class of
> >>NumArray into an instance of the class NumArray. However, it doesn't do
> >>It would help if there were a clearer distinction between the functions
> >>array and inputarray. The former would appear to cast a wider net and,
> >>among other things, include files.
> >This is a mess, I have to agree. The most important distinction is that
> >array() makes a copy of an array by default, while
> >inputarray()/asarray() does not.
> >>I wonder whether there is a need for both array and input array,
> >>wouldn't it be best to focus on the function with the more general utility?
> >Based on your input, and Tim Hochberg's earlier comments, I think we
> >1. Clean up the array function by ditching the buffer/sequence keyword
> >deprecation code. buffer has been deprecated long enough.
> Good! Although it means some changes in my not fully tested code. I
> believe that sequence can also be a buffer, as long as type and shape
> are also provided. I haven't yet tried this.
> >2. Redefine asarray() as calling array() with copy=1. Tim's right.
> >It's a better name than inputarray() and we want it for backward
> >compatibility anyway.
> Good! Although it would be good to make provision for this to convert a
> sub-class instance into an instance of NumArray, something like:
> if instance(sequence, NumArray):
> if sequence.__class__ != NumArray.__class__:
> sequence.__class__ = NumArray.__class__
> copy= True
I'd like to hear more opinions on this.
> >3. Redefine inputarray() as a non-recommended synonym for asarray().
> >I'd say deprecate it, but that's a PITA for anyone already using it.
> It wouldn't be that much of a pain if the deprecation were in the
> documentation only and put into the code after say a year.
Consider it done and get back to me in a year.
> >4. Change the manual to document asarray() as primary and document
> >inputarray() as a non-recommended synonym.
> Yes. Incidentally, what is the current status of the documentation?
> The last time I looked, it was for version 0.7.
JC Hsu did a lot of work revising the manual. I just posted the new
version on Source Forge as part of the 0.8 file release.
Todd Miller <jmiller at stsci.edu>
More information about the Numpy-discussion