[Numpy-discussion] numpy array change notifier?
Erik Tollerud
erik.tollerud@gmail....
Mon Oct 27 15:54:09 CDT 2008
Is there any straightforward way of notifying on change of a numpy
array that leaves the numpy arrays still efficient?
That is, I would like to do the following:
class C:
def __init__(self,arr):
self.arr = arr
#what code do put here?
def notify(self):
print 'do something fun and exciting'
>>>o = C(array([1,2,3,4]))
>>>print o.arr #just print the array
[1 2 3 4]
>>>edarr = o.arr
>>>edarr[2] = 10 #this should now call the notify method
do something fun and exciting
>>>print o.arr
[1 2 10 4]
So is there a means of registering the array or, failing that, setting
up the class so that all the numpy tricks work with o.arr[whatever]
while allowing me to implement a property that calls the notifier?
More information about the Numpy-discussion
mailing list