[Numpy-discussion] trouble subclassing ndarray

Kevin Jacobs <jacobs@bioinformed.com> bioinformed@gmail....
Wed Dec 3 09:32:19 CST 2008


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[:] = ....".

-Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081203/beb187fb/attachment.html 


More information about the Numpy-discussion mailing list