[Numpy-discussion] trouble subclassing ndarray

Sébastien Barthélemy barthelemy@crans....
Wed Dec 3 09:43:59 CST 2008


2008/12/3 Kevin Jacobs <jacobs@bioinformed.com> <bioinformed@gmail.com>:
> On Wed, Dec 3, 2008 at 9:19 AM, Sébastien Barthélemy <barthelemy@crans.org>
> wrote:
>>
>>    def inv_v1(self):
>>        self[0:4,0:4] = htr.inv(self)
>>    def inv_v2(self):
>>        data = htr.inv(self)
>>        self = HomogeneousMatrix(data)
>>    def inv_v3(self):
>>        self = htr.inv(self)
>
> self is a reference, so you're just overwriting it with references to new
> values in v2 and v3.  The original object is unchanged.  Only v1 changes
> self.  You may want to use "self[:] = ....".

okay, it seems obvious now. I definitely spent to much time with matlab.

Thanks


More information about the Numpy-discussion mailing list