[Numpy-discussion] why numarray.inputarray?

Colin J. Williams cjw at sympatico.ca
Tue Feb 10 13:18:21 CST 2004


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?
>>>
>>>-tim
>>>      
>>>
>>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 
>>that.
>>
>>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
>should:
>
>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

>
>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.

>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.

Colin W.

>
>Comments?
>
>Todd
>
>  
>
>>Colin W.
>>
>>    
>>
>>>
>>>-------------------------------------------------------
>>>The SF.Net email is sponsored by EclipseCon 2004
>>>Premiere Conference on Open Tools Development and Integration
>>>See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
>>>http://www.eclipsecon.org/osdn
>>>_______________________________________________
>>>Numpy-discussion mailing list
>>>Numpy-discussion at lists.sourceforge.net
>>>https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>>>
>>>      
>>>
>>
>>-------------------------------------------------------
>>The SF.Net email is sponsored by EclipseCon 2004
>>Premiere Conference on Open Tools Development and Integration
>>See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
>>http://www.eclipsecon.org/osdn
>>_______________________________________________
>>Numpy-discussion mailing list
>>Numpy-discussion at lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>>    
>>





More information about the Numpy-discussion mailing list