[Numpy-discussion] subclassing ndaray
Colin J. Williams
cjw at sympatico.ca
Mon Feb 27 19:23:04 CST 2006
Travis Oliphant wrote:
> Stefan van der Walt wrote:
>>> The __init__ and __new__ methods are not called because they may
>>> have arbitrary signatures. Instead, the __array_finalize__ method
>>> is always called. So, you should use that instead of __init__.
> This is now true in SVN. Previously, __array_finalize__ was not
> called if the "parent" was NULL. However, now, it is still called
> with None as the value of the first argument.
> Thus __array_finalize__ will be called whenever ndarray.__new__(<some
> subclass>,...) is called.
Why this change in style from the the common Python idom of __new__,
__init__, with the same signature to __new__, __array_finalize__ with
possibly different signatures?
Incidentally, what are the signatures? The doc string is empty:
More information about the Numpy-discussion