Hello guys, currently I'm trying to make neighbors tree algorithms to support Cython fused types so that the memory needed can be drastically reduced.
However, both KDTree and BallTree are subclasses of BinaryTree, and this line of BinaryTree seems to decide the datatype (np.float64) of data it stores at initialization time, i.e., even before it sees the actual datatype of training data (which may be np.float32).
The reason to initialize array in __cinit__ is explained in the comments of code:
# Use cinit to initialize all arrays to empty: this will prevent memory
# errors and seg-faults in rare cases where __init__ is not called
I wonder what is the rare cases where __init__ is not called?
Can we handle those rare cases as special cases and move the data initialization to __init__, so that it can init a array of datatype of training data?
Thanks in advance.
ping @jakevdp @jnothman @MechCoder
Hello guys, currently I'm trying to make neighbors tree algorithms to support Cython fused types so that the memory needed can be drastically reduced.
However, both
KDTreeandBallTreeare subclasses ofBinaryTree, and this line ofBinaryTreeseems to decide the datatype (np.float64) of data it stores at initialization time, i.e., even before it sees the actual datatype of training data (which may benp.float32).The reason to initialize array in
__cinit__is explained in the comments of code:I wonder what is the
rare cases where __init__ is not called?Can we handle those rare cases as special cases and move the data initialization to
__init__, so that it can init a array of datatype of training data?Thanks in advance.
ping @jakevdp @jnothman @MechCoder