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 modify the object that self previously pointed to. I didn't try it, but it should work with
def append(self, other): numpy.ndarray.append(self, other) which will call the append method of the parent class numpy.ndarray, modifying self in-place. -=- Olivier Le 31 mars 2012 02:25, Prashant Saxena <animator...@yahoo.com> a écrit : > 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 syntax (numpy syntax) is working but "vary.append(v1)" is > not working. > > Any help? > > Cheers > > Prashant > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion