[Numpy-discussion] Subclassing and metadata
oliphant at ee.byu.edu
Tue Apr 12 16:39:23 CDT 2005
I think I've found a possible solution for subclasses that want to
Essentially, any subclass that defines the method _update_meta(self, other)
will get that method called when an array is sliced, or subscripted.
Anytime an array is created where a subtype is the caller, this method
will be called if it is available.
Here is a simple example:
def __new__(self, shape, *args, **kwds):
self = ndarray.ndarray.__new__(subclass, shape, 'V4')
def __init__(self, shape, *args, **kwds):
self.dict = kwds
def _update_meta(self, obj):
self.dict = obj.dict
More information about the Numpy-discussion