[Numpy-discussion] trouble subclassing ndarray

Kevin Jacobs <jacobs@bioinformed.com> bioinformed at gmail.com
Wed Dec 3 10:32:19 EST 2008


On Wed, Dec 3, 2008 at 9:19 AM, Sébastien Barthélemy
<barthelemy at 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://mail.python.org/pipermail/numpy-discussion/attachments/20081203/beb187fb/attachment.html>


More information about the NumPy-Discussion mailing list