[Numpy-discussion] Ransom Proposals

Travis Oliphant oliphant at ee.byu.edu
Mon Mar 27 10:58:00 CST 2006


Zachary Pincus wrote:

> Speaking of differences between numpy functions and ndarray methods,  
> numpy.resize(...) pads out enlarged arrays with copies of the  
> contents of that array, while ndarray.resize(...) pads out enlarged  
> regions with zeros.


Yep,  this is a documented difference.    I can see desireability of 
both behaviors, but I agree that using the same name for different 
behaviors (without a keyword flag) is not a good idea.

>
> Should these be reconciled as well? I'm partial to the former case,  
> but if there was (perhaps there already is?) another simple way to  
> achieve this result, then it wouldn't matter which semantics were  
> chosen.
>
> To retain compatibility with Numeric, either numpy.resize would need  
> to retain its current semantics, or a function that does the same  
> task (expanding and padding out an array with copies of its contents)  
> would need to be added, so that references to resize in old code  
> could be replaced by calls to that function.

I think for consistency we should make a new function and then add it to 
the list of replaced functions in convertcode.py

The other possibility that I'm liking more is to use a keyword argument 
that specifies a fill-value.   The default for the method could be 0 
while the default for the resize-function could be the array itself.

True, different default keywords may not be convenient (but that exists 
already with the axis keyword for many methods and is done for backwards 
compatibility).

All the code review is great.  Please continue it. 


-Travis






More information about the Numpy-discussion mailing list