[Numpy-discussion] numpy array change notifier?

Erik Tollerud erik.tollerud at gmail.com
Mon Oct 27 16:54:09 EDT 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