Cell Lists

Cell lists is an algorithm for computing fast fixed-radius nearest neighbors search. This documentation contains the API of the cell_lists package.

API

cell_lists.core.add_to_cells[source]

Sorts the indices of the points into the grid by the given cell size.

Parameters
  • points (array of floats) – Two dimensional array of points where rows are the individual points and columns are the dimensions.

  • cell_size (float) – Positive real number denoting the cell size of the grid.

Returns

Tuple of four arrays where the arrays are

  1. points_indices – Array of integers for querying the indices of nearest neighbors.

  2. cells_count – Array of integers denoting the number of points inside each cell.

  3. cells_offset – Array of integers denoting the offset index for each cell in points_indices array.

  4. grid_shape – Array of integers denoting the shape of the output grid.

Return type

(numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray)

cell_lists.core.neighboring_cells(grid_shape, distance=1)[source]

Neighboring cells.

Parameters
  • grid_shape (numpy.ndarray) – Grid shape from add_to_cells function.

  • distance (int) – Positive integer denoting the maximum distance of nearest neighboring cells. Has a default value of 1.

Returns

Array of differences of the indices of neighboring cells.

Return type

numpy.ndarray

cell_lists.core.find_points_in_cell[source]

Find indices of points inside cell of index cell_index.

Parameters
  • cell_index (int) – Integer denoting an index of a cell.

  • points_indices (numpy.ndarray) – Value obtained from add_to_cells function.

  • cells_count (numpy.ndarray) – Value obtained from add_to_cells function.

  • cells_offset (numpy.ndarray) – Value obtained from add_to_cells function.

Returns

Array of integers denoting the indices of points that belong into the cell of index cell_index. Subset of points_indices

Return type

numpy.ndarray

cell_lists.core.iter_nearest_neighbors[source]

Iterate over cell lists to find all the nearest neighbor pairs of points.

Parameters
  • cell_indices (numpy.ndarray) – Indices of the cells to which iterate over. By default, use np.arange(len(cells_count))

  • neigh_cells (numpy.ndarray) – Neighboring cell from neighboring_cells function.

  • points_indices (numpy.ndarray) – Value obtained from add_to_cells function.

  • cells_count (numpy.ndarray) – Value obtained from add_to_cells function.

  • cells_offset (numpy.ndarray) – Value obtained from add_to_cells function.

Yields

(int, int) – Tuple of indices of a pair of nearest neighbors.