On Jul 23, 2009, at 1:13 PM, Jacopo wrote:
>
> In short, I want to create a class Dummy, inherited from np.ndarray,
> which
> returns a plain array whenever an instance is sliced or viewed. I
> cannot figure
> out how.
Easy enough for slices:
class Dummy(np.ndarray):
def __new__(cls, array):
obj=array.view(cls)
return obj
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 ?
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion