nearest_element#
- class brainpy.state.spatial.nearest_element(layer, locations, find_all=False)[source]#
Local index of the node nearest each query location (NEST
FindNearestElement).- Parameters:
layer (
Layer) – A concrete position layer.locations (
sequenceorQuantity) – A single coordinate(ndim,)or a list of coordinates(m, ndim). Bare floats are taken in micrometres.find_all (
bool, optional) – WhenFalse(default), ties resolve to the lowest index. WhenTrue, every node within|d - d_min| <= 1e-14 * d_minof the minimum is returned.
- Returns:
For a single location: an
int(find_all=False) or a list of ints (find_all=True). For a list of locations: a list with one such entry per location.- Return type:
Examples
>>> from brainpy import state as bp >>> bp.spatial.nearest_element(bp.spatial.grid([3, 1], extent=[3.0, 1.0]), [0.9, 0.0]) 2