Neighbours¶
knn_graph
¶
knn_graph(
X: Any,
k: int = 15,
*,
metric: str = "euclidean",
ann: str = "kmknn",
nn_params: NeighbourParams | None = None,
seed: int = 42,
verbose: int = 0,
) -> tuple[ndarray, ndarray]
Build a k-nearest-neighbour graph over X.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
Any
|
Array-like of shape |
required |
k
|
int
|
Neighbours per point, excluding self. |
15
|
metric
|
str
|
|
'euclidean'
|
ann
|
str
|
|
'kmknn'
|
nn_params
|
NeighbourParams | None
|
Backend-specific knobs. See |
None
|
seed
|
int
|
Fixes anything randomised in the build. |
42
|
verbose
|
int
|
|
0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
distances match the dtype of |
tuple[ndarray, ndarray]
|
it is the order the estimators take them in. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
set_num_threads
builtin
¶
num_threads
builtin
¶
Threads the core will use for the next call.
Returns¶
The configured cap, or rayon's global pool size when none was set.
gpu_available
builtin
¶
Whether the GPU entry points can be used here.
Returns¶
True only when this build has the gpu feature and wgpu resolves an
adapter. Safe to call on any machine.
Note¶
Acquiring a client panics rather than erroring when no adapter is found, so
the probe catches it. That is sound here because the release profile is
pinned to panic = "unwind", which pyo3 requires anyway. The panic hook is
silenced for the duration, otherwise merely asking the question prints a
backtrace to stderr.