skbio.tree.BPTree.numba_arrays#
- BPTree.numba_arrays(gpu=None)[source]#
The tree’s arrays, for the Numba navigation functions.
- Parameters:
- gpumodule, optional
A Numba GPU module (
numba_cuda_mlir.cudaornumba.cudaon NVIDIA,numba.hipon AMD) to place the arrays on a GPU: that of the tree’s data if it is on one, else the module’s current device. By default they stay on the host, for CPU code.
- Returns:
- tuple
An opaque bundle
Tof the tree’s topology and navigation index, passed to the functions ofskbio.tree.bp.numbaas their first argument, e.g.nav.parent(T, i).T.sizeis the number of parentheses.
See also
Notes
On the host,
Tholds read-only views of the tree’s own arrays: no copy is made. On a GPU, they are uploaded on the first call and cached on the tree, so later calls (and the batch operations withengine="numba") reuse them. This is so whether or not the tree was created from an array on the device.The topology cannot change once the tree exists, so
Tstays valid as long as the tree. Node attributes can be replaced (e.g. withset_lengths), which is why they are not part ofT: passlengthsoredgesto a kernel as arguments of their own.Examples
>>> from skbio.tree import BPTree >>> tree = BPTree.read(["((a:1,b:2)c:3,(d:4,e:5)f:6)root;"]) >>> T = tree.numba_arrays() >>> T.size 14