GriSPy (Grid Search in Python)
GriSPy is a regular grid search algorithm for quick nearest-neighbor lookup.
This class indexes a set of k-dimensional points in a regular grid providing a fast aproach for nearest neighbors queries. Optional periodic boundary conditions can be provided for each axis individually.
GriSPy has the following queries implemented:
- bubble_neighbors: find neighbors within a given radius. A different radius for each centre can be provided.
- shell_neighbors: find neighbors within given lower and upper radius. Different lower and upper radius can be provided for each centre.
- nearest_neighbors: find the nth nearest neighbors for each centre.
Usage example
Let's create a 2D random distribution of points as an example:
import numpy as np
import grispy as gsp
data = np.random.uniform(size=(1000, 2))
grid = gsp.GriSPy(data)
The grid object now has all the data points indexed in a grid. Now let's search for neighbors around new points:
centres = np.random.uniform(size=(10, 2))
dist, ind = grid.bubble_neighbors(centres, distance_upper_bound=0.1)
And that's it! The dist and ind lists contain the distances and indices to data neighbors within a 0.1 search radius.
Requirements
You will need Python 3.11 or later to run GriSPy.
Standard Installation
GriSPy is available at PyPI. You can install it via the pip command
$ pip install grispy
Development Install
Clone this repo and then inside the local directory execute
$ pip install -e .
Citation
If you use GriSPy in a scientific publication, we would appreciate citations to the following paper:
Chalela, M., Sillero, E., Pereyra, L., García, M. A., Cabral, J. B., Lares, M., & Merchán, M. (2020). GriSPy: A Python package for fixed-radius nearest neighbors search. 10.1016/j.ascom.2020.100443.
Bibtex
@ARTICLE{Chalela2021,
author = {{Chalela}, M. and {Sillero}, E. and {Pereyra}, L. and {Garcia}, M.~A. and {Cabral}, J.~B. and {Lares}, M. and {Merch{\'a}n}, M.},
title = "{GriSPy: A Python package for fixed-radius nearest neighbors search}",
journal = {Astronomy and Computing},
keywords = {Data mining, Nearest-neighbor search, Methods, Data analysis, Astroinformatics, Python package},
year = 2021,
month = jan,
volume = {34},
eid = {100443},
pages = {100443},
doi = {10.1016/j.ascom.2020.100443},
adsurl = {https://ui.adsabs.harvard.edu/abs/2021A&C....3400443C},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
Full-text: https://arxiv.org/abs/1912.09585
Authors
Martin Chalela (E-mail: mchalela@unc.edu.ar), Emanuel Sillero, Luis Pereyra, Alejandro Garcia, Juan B. Cabral, Marcelo Lares, Manuel Merchán.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grispy-0.3.0.tar.gz.
File metadata
- Download URL: grispy-0.3.0.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0c94b0891cf969ebfe0661bf76a29ba5754d92ce91584daa55573893a749d6b
|
|
| MD5 |
de8a9e6a10b28fc3daafdcb572c8525c
|
|
| BLAKE2b-256 |
b2323d5d78a75acf31d781f325bace333f2f1d88fcdbdd0b65f32c6fca798695
|
File details
Details for the file grispy-0.3.0-py3-none-any.whl.
File metadata
- Download URL: grispy-0.3.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
152217310fc39f643a6f33e76f630649fb1f0e3213e4afa001958efab3cc7369
|
|
| MD5 |
d300281b53e471ff42eeb61e78d2186e
|
|
| BLAKE2b-256 |
fa2b776742ec00ed1c39e372db67ce6011cfa65f670e8a547165bacde2791801
|