Neal Becker wrote: > I wanted the function of an array that accumulates my results, it starts > at > zero size, and resizes as needed. New results are added using > > accumulated += new_array > > A simple implementation of this is here: > > https://gist.github.com/2ab48e25fd460990d045.git > > I have 2 questions: > > 1. Is this a reasonable approach? > > 2. I overloaded += to do 1) resize 2) call ndarray += operator > Is there some way to just overload all arithmetic operators similarly all > at > the same time? (I don't need them for the current work, I'm just > curious).
Well one thing, due to (what IMO is) a bug in pickle, https://bugs.python.org/issue5370 you need to modify, this seems to work: def __getattr__(self, name): # delegate all operations not specifically overridden to base array if 'arr' in self.__dict__: # this is to allow unpickle avoid infinite recursion return getattr (self.arr, name) raise AttributeError(name) _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
