[Numpy-discussion] can't resize ndarray subclass

Travis Oliphant oliphant.travis at ieee.org
Tue Feb 28 12:03:09 EST 2006

Zachary Pincus wrote:

> Thus far, it seems like the way to get instances of ndarray  
> subclasses is to use the 'view(subclass)' method on a proper ndarray,  
> either in the subclass __new__, or after constructing the array.
> However, subclass instances so created *do not own their own data*,  
> as far as I can tell. They are just "views" on an other array's data.  
> This means that these objects can't be resized, or have other  
> operations performed on them which requires 'owning' the data buffer.

Yes, that is true.   To own your own data your subclass would have to 
create it's own memory using

ndarray.__new__(mysubclass, shape, dtype)

Or make a copy as you suggested later.


More information about the NumPy-Discussion mailing list