radius
¶
radius(
x: array,
y: array,
r: float,
batch_x: Optional[array] = None,
batch_y: Optional[array] = None,
max_num_neighbors: Optional[int] = 32,
num_graphs: Optional[int] = None,
) -> array
Finds for each point of y the points of x within distance r.
Only points of the same graph are matched when batch vectors are given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
Points to search in, of shape |
required |
y
|
array
|
Query points, of shape |
required |
r
|
float
|
The radius. Points at a distance strictly smaller than |
required |
batch_x
|
Optional[array]
|
Graph of each point of |
None
|
batch_y
|
Optional[array]
|
Graph of each point of |
None
|
max_num_neighbors
|
Optional[int]
|
The maximum number of neighbors returned for each
query point; the closest ones are kept. |
32
|
num_graphs
|
Optional[int]
|
Number of graphs. Default: |
None
|
Returns:
| Type | Description |
|---|---|
array
|
An array of shape |
array
|
each query point of |
array
|
in |
Example:
import mlx.core as mx
from mlx_graphs.utils import radius
x = mx.array([[-1.0, -1.0], [-1.0, 1.0], [1.0, -1.0], [1.0, 1.0]])
y = mx.array([[-1.0, 0.0], [1.0, 0.0]])
assign_index = radius(x, y, 1.5)
>>> assign_index
array([[0, 0, 1, 1],
[0, 1, 2, 3]], dtype=int32)
Source code in mlx_graphs/utils/spatial.py
from mlx_graphs.nn import radius · mlx_graphs/utils/spatial.py