[Numpy-discussion] numpy subclass
Thu Jul 23 12:30:23 CDT 2009
On Jul 23, 2009, at 1:13 PM, Jacopo wrote:
> In short, I want to create a class Dummy, inherited from np.ndarray,
> returns a plain array whenever an instance is sliced or viewed. I
> cannot figure
> out how.
Easy enough for slices:
def __new__(cls, array):
def __getslice__(self, i, j):
return np.ndarray.__getslice__(self, i, j).view(np.ndarray)
For views, the problem needs to be better described: why would you
want to get just a basic ndarray ?
More information about the NumPy-Discussion