[Numpy-discussion] subclassing float64 (and friends)
oliphant at ee.byu.edu
Fri Jan 5 09:23:35 EST 2007
Stefan van der Walt wrote:
> On Wed, Jan 03, 2007 at 05:12:40PM -0600, eric jones wrote:
>> Thanks for the update. For now, I'll try doing what I need to by
>> sub-classing float. But, I'm gonna miss __array_finalize__ :-).
> Looks like r3493 is intended to fix this. The 'view' method works
> now, but I still see
> In : import numpy as N
> In : x = N.float64(12)
> In : class Floaty(N.float64):
> ...: def __new__(subclass,data):
> ...: return data.view(subclass)
> In : Floaty(x)
> Out: 12.0
> In : type(Floaty(x))
> Out: <type 'numpy.float64'>
I did not change the view method. This will still always return
base-class array scalars. Could look into it.
There is no __array_finalize__, however, for array scalars.
More information about the NumPy-Discussion