[Numpy-discussion] Expanding an array by assignment

Travis Oliphant oliphant at ee.byu.edu
Thu Feb 17 11:48:21 CST 2005


Darren Dale wrote:

>Has Numeric or numarray considered allowing assignment to invalid indices? I 
>sometimes miss being able to do this:
>a=zeros(2)
>a[1:0]=1
>
>in order to get this:
>[[0,0],
> [1,0]]
>
>I guess it is not consistent with the list operations in python, but it is a 
>really handy shortcut for constructing arrays interactively.
>  
>

I'm not sure what you meant by this.  Did you mean being able to expand 
an array only by assignment?

i.e.

a = zeros(2)  a (2,1) array

a[1,0] = 1    (resizes a behind the scenes to a 2x2 array and then sets 
the 1,0 element)?

MATLAB does display this behavior.  I'm not sure how difficult it would 
be to support it or if it would be worth it or not.  What does IDL do? 

-Travis





More information about the Numpy-discussion mailing list