[Numpy-discussion] subclassing float64 (and friends)
Travis Oliphant
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 [2]: import numpy as N
>
> In [3]: x = N.float64(12)
>
> In [4]: class Floaty(N.float64):
> ...: def __new__(subclass,data):
> ...: return data.view(subclass)
>
> In [6]: Floaty(x)
> Out[6]: 12.0
>
> In [7]: type(Floaty(x))
> Out[7]: <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.
-Travis
More information about the NumPy-Discussion
mailing list