pairlist
Fast neighbor (pair) lists for particles under periodic boundary conditions.
Given coordinates and a cutoff, it yields index pairs ((i, j)) whose distance is below the threshold. Internally it uses a cell-list algorithm with an optional C extension.
version 1.0.1
Install
pip install pairlist
Quick start
No external data files are required—only NumPy.
import numpy as np
import pairlist as pl
N = 500
cell = np.eye(3) * 20.0 # 20 × 20 × 20 box
pos = np.random.default_rng(0).random((N, 3)) # fractional coordinates
for i, j, r in pl.pairs_iter(pos, maxdist=3.0, cell=cell):
# i, j: particle indices; r: distance in the same unit as cell
print(i, j, r)
Absolute coordinates work the same way if you set fractional=False:
pos_abs = pos @ cell
for i, j, r in pl.pairs_iter(
pos_abs, maxdist=3.0, cell=cell, fractional=False
):
...
Pairs between two sets of points:
pos_A = np.random.default_rng(1).random((100, 3))
pos_B = np.random.default_rng(2).random((200, 3))
for i, j, r in pl.pairs_iter(pos_A, maxdist=3.0, cell=cell, pos2=pos_B):
...
API reference: pairlist.html
Demo: draw neighbor bonds
Particles in a periodic box; lines are pairs within the cutoff (colored by distance; minimum-image segments). Regenerate with:
python samples/demo_bonds.py -o benchmark/demo.png
Minimal version:
import numpy as np
import matplotlib.pyplot as plt
import pairlist as pl
rng = np.random.default_rng(0)
cell = np.eye(3) * 10.0
pos = rng.random((80, 3))
xyz = pos @ cell
fig, ax = plt.subplots(figsize=(5, 5))
ax.scatter(xyz[:, 0], xyz[:, 1], s=12, zorder=2)
for i, j, _ in pl.pairs_iter(pos, maxdist=2.0, cell=cell):
ax.plot(
[xyz[i, 0], xyz[j, 0]],
[xyz[i, 1], xyz[j, 1]],
color="0.6",
lw=0.6,
zorder=1,
)
ax.set_aspect("equal")
ax.set_title("pairs within cutoff (xy projection)")
plt.show()
Benchmark
Cell lists vs. naive (O(N^2)) and other methods:
C / other languages
The core cell-list routines are also available as a small C library
(csource/pairlist.h, libpairlist.a). See the header for the API.
Optional: GenIce samples
The scripts under samples/ (RDF, hydrogen-bond graph, …) read Gromacs-style
coordinates. You can generate an example box with
GenIce:
genice2 CRN1 -r 2 2 2 > CRN1x222.gro
python samples/RDF_pairlist.py < CRN1x222.gro
Or simply make test if GenIce is installed.
Requirements
- python
- numpy
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 pairlist-1.0.1.tar.gz.
File metadata
- Download URL: pairlist-1.0.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
580596546dbcb4f7fefb911b3794e256408ddb9231ff9df9f64b3de9d730bce2
|
|
| MD5 |
632d1995ea57a7dbd0cfaf7107c9439f
|
|
| BLAKE2b-256 |
2ef0a6be32a39d6243bf16d9de1a3d9ad93d6e0ef11fa866ee0d7a7fee0490a7
|
File details
Details for the file pairlist-1.0.1-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 24.3 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e685ab103887f6f3ab5282b5cbdfe28441d0eac9371ccf0ba190c9ac268aa66
|
|
| MD5 |
3c1f3f4206597bbb7327997b4bd8b077
|
|
| BLAKE2b-256 |
6be33d9e9c7fb6b0656090787297680e12fae6c7bf4bc56fb1b854ba7323793b
|
File details
Details for the file pairlist-1.0.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 79.5 kB
- Tags: CPython 3.14, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ba84d672679adadfa4a326ab15a83c51c918e7b08b4d1f9d6b165a042957160
|
|
| MD5 |
dcea2ff9afe17c59e80fe6c8a4389418
|
|
| BLAKE2b-256 |
63f6cb6c7d96065faceb95aa7b1b11f4c7749298269200cfc37bb1ad9eddf4fe
|
File details
Details for the file pairlist-1.0.1-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.5 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35d32db23f52da375f5b6674d1577671357107520d700be0746df778a9fc2f1b
|
|
| MD5 |
dc922bca5d95838bc4fc3773e2a193d4
|
|
| BLAKE2b-256 |
e47a57632641c81eda31b6dad25e24767867085c0c2f59d48395b20a92ba672b
|
File details
Details for the file pairlist-1.0.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 23.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d94e933d6bd82eb53232bd139244f5e134a7b7ccab63a9516207c3506a4b2c1b
|
|
| MD5 |
a6df6d347822620beaa03d5debd22dff
|
|
| BLAKE2b-256 |
4447a39db573cd82fd98d8be18202a8201dbbe07f6f8603e8f685ccc0af50243
|
File details
Details for the file pairlist-1.0.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 79.4 kB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f1c9ac9d9a23c5b22f82ca80a3ac27b6e627bfd9f8ca3f12e24e83a0d783db1
|
|
| MD5 |
2de88adac3b1c306c1d164efeb62a9b5
|
|
| BLAKE2b-256 |
d27c9cbc00f5000173e6e804c96e61bd77e307b2b3b947a7a386394b51c2f8ab
|
File details
Details for the file pairlist-1.0.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.5 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf5e88f7a19705405aa285b2a577323ea7be0b5432fb451aa8750bddb6ea4656
|
|
| MD5 |
0aaec867898f061a7ae8581e075f1e9f
|
|
| BLAKE2b-256 |
c2006f793b4bc8c82dc192d3c234195f0b35bc85c507ce30844b41f00850bfed
|
File details
Details for the file pairlist-1.0.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 23.6 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
435aa0f2a5a3b9d47f09d2f18afa121091ce58638094e0a8d246c5068be6c6a6
|
|
| MD5 |
8e16a5d5284eb540de1b098cd1e00fc4
|
|
| BLAKE2b-256 |
78949bbeafb759b3c14558ad1bd64a86f0a47e58048efcc4040a994a030a2e44
|
File details
Details for the file pairlist-1.0.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 79.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f4c0916570fe14743d518a290803bf5503832cbc725e1bdbc2a400cf6205a0f
|
|
| MD5 |
69f22d0f16c1a3371c5440842486c996
|
|
| BLAKE2b-256 |
1092ca499de87e0ea3df2ea4331cd3a21f672ef16325f807372728fc428d96f0
|
File details
Details for the file pairlist-1.0.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9e49eb52e3eb3b320ca75bc12fedb5d30e1e8179146aab8f485c0ed3e5fb40e
|
|
| MD5 |
f99b130e808a5fd338e5d2ad5fab075f
|
|
| BLAKE2b-256 |
e744a6b2c96de93b08552cf33a718ef3e27804783a2f2c67fef5828428aae77c
|
File details
Details for the file pairlist-1.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 23.5 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffd72ac311c98018dafbaea3eea0077606fa8303f155e636b53601c06e67a450
|
|
| MD5 |
7ac9ea9d9c05c4bf3644f21dbc5decee
|
|
| BLAKE2b-256 |
aaca1d6417c26942f9254e0d0813e297f1acbaf3345aabf70c4e7e26a2620b31
|
File details
Details for the file pairlist-1.0.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 78.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4089ac672fca4d81cfb9a951cb477fb286ff0baef3c820a5aa61a4e83beb6f88
|
|
| MD5 |
720b709866f631d21d06facf832c177f
|
|
| BLAKE2b-256 |
22c3676efa4032a3e9aecbe570c0799024b8014f6bbabf68a20923c5ce01dcd9
|
File details
Details for the file pairlist-1.0.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b08c742ccbde524750f7507d4ee31f66d0a1fe10fceb041b378cf362e6f5a022
|
|
| MD5 |
a433feed256e152fbcbb7c384c1a62bd
|
|
| BLAKE2b-256 |
7d2727e20fe0f1a02052cd9874eb9a63fe4113677b61d708b2a48f2c79b1ea1d
|
File details
Details for the file pairlist-1.0.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 23.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4d98e41efad869557e06d0aaa182eb77277af5e149d58ceccc2a7d6c6576bd8
|
|
| MD5 |
050c8d00999fa1a46544d9008123b350
|
|
| BLAKE2b-256 |
a18165496cb9443749e0b5de2a1c9aea688e4716ee2d8d3bf64bf01cba521c60
|
File details
Details for the file pairlist-1.0.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 77.1 kB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf8b8cfc36ca5a885d074d61a8a34b752cf80bb4159abacb8769750ea4393758
|
|
| MD5 |
8f607587f98b9c1f64a742a764633225
|
|
| BLAKE2b-256 |
f006bc9dd0c13a2a59f7669daf1af9aafb924ab88ceaf2b0a6112bb64ab8ca24
|
File details
Details for the file pairlist-1.0.1-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.5 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6378580f1e69046c5fc9ce462b885393e5ecf477ee40a3f7966e362077c207fb
|
|
| MD5 |
03273df5a86ed3aa4b83dba2f20a1ea4
|
|
| BLAKE2b-256 |
aacb548c23e3c619edba34b688f0689603da6506619035b9a434174bcc16fdb1
|
File details
Details for the file pairlist-1.0.1-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 23.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
711518e661261def79587239b46867e6f929b611d84e5d377ca709cb1c0a2fb6
|
|
| MD5 |
51761de3bfa71d193a5e470fc82d36cf
|
|
| BLAKE2b-256 |
cddece696a07ca3f094c203db5d5902b7e5d6ac328defd0e78490e53b83ee417
|
File details
Details for the file pairlist-1.0.1-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 76.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fba581dcf757950349e5b9201bdaba872fa6ceafb34ddf2a8a3965fe8b2fc45b
|
|
| MD5 |
66e69e60cf30fbf30ba0f0fc15f412dd
|
|
| BLAKE2b-256 |
df7f4b0d5a8fec00b116b960322292654dfbde6d7881b45a31ee84d7d551e387
|
File details
Details for the file pairlist-1.0.1-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: pairlist-1.0.1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.5 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7424ec5669888b076dbc3653c1e3cfe3e5b538753e2f24fb0a9d0fbbc4453166
|
|
| MD5 |
2390ac9ba5bd3bafd98a6482548603ed
|
|
| BLAKE2b-256 |
0b2fc9a0feaee390ae1752f07ff69aa068213adc52a970d1b864a9d92300fb57
|