April 12, 2005
4:39 p.m.
I think I've found a possible solution for subclasses that want to handle metadata. 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: import ndarray class subclass(ndarray.ndarray): def __new__(self, shape, *args, **kwds): self = ndarray.ndarray.__new__(subclass, shape, 'V4') return self def __init__(self, shape, *args, **kwds): self.dict = kwds return def _update_meta(self, obj): self.dict = obj.dict Comments? -Travis
7817
Age (days ago)
7817
Last active (days ago)
0 comments
1 participants
participants (1)
-
Travis Oliphant