Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Any way to make BinaryTree support fused type? #7059

Open
@yenchenlin

Description

@yenchenlin

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions