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
Metadata
Release files for pairlist 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pairlist-1.0.1.tar.gz | 17.5 kB | Details |
Built distributions (wheels)
Total release size: 752.3 kB
Release files / pairlist-1.0.1.tar.gz
| Download URL | pairlist-1.0.1.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
580596546dbcb4f7fefb911b3794e256408ddb9231ff9df9f64b3de9d730bce2
|
|
BLAKE2b-256 checksum How to use checksums |
2ef0a6be32a39d6243bf16d9de1a3d9ad93d6e0ef11fa866ee0d7a7fee0490a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp314-cp314-win_amd64.whl
| Download URL | pairlist-1.0.1-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 24.3 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1e685ab103887f6f3ab5282b5cbdfe28441d0eac9371ccf0ba190c9ac268aa66
|
|
BLAKE2b-256 checksum How to use checksums |
6be33d9e9c7fb6b0656090787297680e12fae6c7bf4bc56fb1b854ba7323793b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | pairlist-1.0.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 79.5 kB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
4ba84d672679adadfa4a326ab15a83c51c918e7b08b4d1f9d6b165a042957160
|
|
BLAKE2b-256 checksum How to use checksums |
63f6cb6c7d96065faceb95aa7b1b11f4c7749298269200cfc37bb1ad9eddf4fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | pairlist-1.0.1-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 20.5 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
35d32db23f52da375f5b6674d1577671357107520d700be0746df778a9fc2f1b
|
|
BLAKE2b-256 checksum How to use checksums |
e47a57632641c81eda31b6dad25e24767867085c0c2f59d48395b20a92ba672b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp313-cp313-win_amd64.whl
| Download URL | pairlist-1.0.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 23.6 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d94e933d6bd82eb53232bd139244f5e134a7b7ccab63a9516207c3506a4b2c1b
|
|
BLAKE2b-256 checksum How to use checksums |
4447a39db573cd82fd98d8be18202a8201dbbe07f6f8603e8f685ccc0af50243
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | pairlist-1.0.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 79.4 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
2f1c9ac9d9a23c5b22f82ca80a3ac27b6e627bfd9f8ca3f12e24e83a0d783db1
|
|
BLAKE2b-256 checksum How to use checksums |
d27c9cbc00f5000173e6e804c96e61bd77e307b2b3b947a7a386394b51c2f8ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | pairlist-1.0.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 20.5 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
cf5e88f7a19705405aa285b2a577323ea7be0b5432fb451aa8750bddb6ea4656
|
|
BLAKE2b-256 checksum How to use checksums |
c2006f793b4bc8c82dc192d3c234195f0b35bc85c507ce30844b41f00850bfed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp312-cp312-win_amd64.whl
| Download URL | pairlist-1.0.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 23.6 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
435aa0f2a5a3b9d47f09d2f18afa121091ce58638094e0a8d246c5068be6c6a6
|
|
BLAKE2b-256 checksum How to use checksums |
78949bbeafb759b3c14558ad1bd64a86f0a47e58048efcc4040a994a030a2e44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | pairlist-1.0.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 79.3 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
9f4c0916570fe14743d518a290803bf5503832cbc725e1bdbc2a400cf6205a0f
|
|
BLAKE2b-256 checksum How to use checksums |
1092ca499de87e0ea3df2ea4331cd3a21f672ef16325f807372728fc428d96f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pairlist-1.0.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 20.5 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f9e49eb52e3eb3b320ca75bc12fedb5d30e1e8179146aab8f485c0ed3e5fb40e
|
|
BLAKE2b-256 checksum How to use checksums |
e744a6b2c96de93b08552cf33a718ef3e27804783a2f2c67fef5828428aae77c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp311-cp311-win_amd64.whl
| Download URL | pairlist-1.0.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 23.5 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ffd72ac311c98018dafbaea3eea0077606fa8303f155e636b53601c06e67a450
|
|
BLAKE2b-256 checksum How to use checksums |
aaca1d6417c26942f9254e0d0813e297f1acbaf3345aabf70c4e7e26a2620b31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | pairlist-1.0.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 78.0 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
4089ac672fca4d81cfb9a951cb477fb286ff0baef3c820a5aa61a4e83beb6f88
|
|
BLAKE2b-256 checksum How to use checksums |
22c3676efa4032a3e9aecbe570c0799024b8014f6bbabf68a20923c5ce01dcd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | pairlist-1.0.1-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 20.5 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b08c742ccbde524750f7507d4ee31f66d0a1fe10fceb041b378cf362e6f5a022
|
|
BLAKE2b-256 checksum How to use checksums |
7d2727e20fe0f1a02052cd9874eb9a63fe4113677b61d708b2a48f2c79b1ea1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp310-cp310-win_amd64.whl
| Download URL | pairlist-1.0.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 23.4 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c4d98e41efad869557e06d0aaa182eb77277af5e149d58ceccc2a7d6c6576bd8
|
|
BLAKE2b-256 checksum How to use checksums |
a18165496cb9443749e0b5de2a1c9aea688e4716ee2d8d3bf64bf01cba521c60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | pairlist-1.0.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 77.1 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
bf8b8cfc36ca5a885d074d61a8a34b752cf80bb4159abacb8769750ea4393758
|
|
BLAKE2b-256 checksum How to use checksums |
f006bc9dd0c13a2a59f7669daf1af9aafb924ab88ceaf2b0a6112bb64ab8ca24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | pairlist-1.0.1-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 20.5 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6378580f1e69046c5fc9ce462b885393e5ecf477ee40a3f7966e362077c207fb
|
|
BLAKE2b-256 checksum How to use checksums |
aacb548c23e3c619edba34b688f0689603da6506619035b9a434174bcc16fdb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp39-cp39-win_amd64.whl
| Download URL | pairlist-1.0.1-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 23.4 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
711518e661261def79587239b46867e6f929b611d84e5d377ca709cb1c0a2fb6
|
|
BLAKE2b-256 checksum How to use checksums |
cddece696a07ca3f094c203db5d5902b7e5d6ac328defd0e78490e53b83ee417
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | pairlist-1.0.1-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 76.8 kB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
fba581dcf757950349e5b9201bdaba872fa6ceafb34ddf2a8a3965fe8b2fc45b
|
|
BLAKE2b-256 checksum How to use checksums |
df7f4b0d5a8fec00b116b960322292654dfbde6d7881b45a31ee84d7d551e387
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pairlist-1.0.1-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | pairlist-1.0.1-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 20.5 kB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7424ec5669888b076dbc3653c1e3cfe3e5b538753e2f24fb0a9d0fbbc4453166
|
|
BLAKE2b-256 checksum How to use checksums |
0b2fc9a0feaee390ae1752f07ff69aa068213adc52a970d1b864a9d92300fb57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|