Re: [Numpy-discussion] ndarray sub-classing and append function

2012-04-01 Thread Tom Aldcroft
On Sat, Mar 31, 2012 at 2:25 AM, Prashant Saxena animator...@yahoo.com wrote: Hi, I am sub-classing numpy.ndarry for vector array representation. The append function is like this:     def append(self, other):        self = numpy.append(self, [other], axis=0) Example: vary =

Re: [Numpy-discussion] ndarray sub-classing and append function

2012-04-01 Thread Chris Barker
On Sun, Apr 1, 2012 at 8:19 AM, Tom Aldcroft aldcr...@head.cfa.harvard.edu wrote: You might try something like below (untested code, just meant as pointing in the right direction): self.resize(len(self) + len(v1), refcheck=False) self[len(self):] = v1 Setting refcheck=False is potentially

[Numpy-discussion] ndarray sub-classing and append function

2012-03-31 Thread Prashant Saxena
Hi, I am sub-classing numpy.ndarry for vector array representation. The append function is like this:     def append(self, other):        self = numpy.append(self, [other], axis=0) Example: vary = VectorArray([v1, v2]) #vary = numpy.append(vary, [v1], axis=0) vary.append(v1) The commented

Re: [Numpy-discussion] ndarray sub-classing and append function

2012-03-31 Thread Olivier Delalleau
It doesn't work because numpy.append(a, ...) doesn't modify the array a in-place: it returns a copy. Then in your append method, doing self = numpy.append(...) won't have any effect: in Python such a syntax means the self local variable will now point to the result of numpy.append, but it won't