nearest_element

Contents

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 (sequence or Quantity) – A single coordinate (ndim,) or a list of coordinates (m, ndim). Bare floats are taken in micrometres.

  • find_all (bool, optional) – When False (default), ties resolve to the lowest index. When True, every node within |d - d_min| <= 1e-14 * d_min of 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:

int or list

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