[Numpy-discussion] Ransom Proposals

Zachary Pincus zpincus at stanford.edu
Sun Mar 26 17:11:21 EST 2006


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.

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.

Zach


>> Mmh.  I bet many people will continue to use the functional  
>> interface for a long time.  I'd vote for uniform semantics before  
>> 1.0.  Really, the whole 'reshape(foo) and foo.reshape() have  
>> different view/copy behavior' thing is horrible.  WAY too easy to  
>> forget/confuse.  Special cases are /almost never/ special enough  
>> to warrant this kind of extra mental overhead.
>>
>> At least I know /I/ will forget, get confused, and make mistakes.   
>> So I'd like to ask for as-uniform-as possible behavior.
>>
> +1
> Perhaps most of the functions could be in a compatibility module,  
> which the user would import as needed, with most cases defined as  
> something like:
> reshape(arr, d1, d2, ...)= numpy.ndarray.reshape(arr,d1, d2, ...)





More information about the NumPy-Discussion mailing list