Skip to main content

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.2

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

demo

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:

benchmark.ipynb Open In Colab

benchmark

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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pairlist 1.0.2
File Size Uploaded Provenance
pairlist-1.0.2.tar.gz 17.6 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for pairlist 1.0.2
File
pairlist-1.0.2-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pairlist-1.0.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details
pairlist-1.0.2-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
pairlist-1.0.2-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pairlist-1.0.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details
pairlist-1.0.2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
pairlist-1.0.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pairlist-1.0.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.5+ x86-64 Details
pairlist-1.0.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
pairlist-1.0.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pairlist-1.0.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.5+ x86-64 Details
pairlist-1.0.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 510.7 kB

Release files / pairlist-1.0.2.tar.gz

Download URL pairlist-1.0.2.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
75a7dee3fdc10cc7226744b4a6d43c1ec36481ddd9262a973f5d2291996afde4
BLAKE2b-256 checksum
How to use checksums
8782225f54faea69f24deec96c8ead5194c0548b2f70c2a607c41f623b6da4a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp314-cp314-win_amd64.whl

Download URL pairlist-1.0.2-cp314-cp314-win_amd64.whl
Size 24.3 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
d797641e12cf9f2a20bc89fadb18f9dff6cac79755d0572b823f1aca0bbbe03d
BLAKE2b-256 checksum
How to use checksums
f9763578f0f43356f58ec15ae3cd5b22e1203bb7011c6fd576a2830ac0c5b9c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL pairlist-1.0.2-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
aad3fa1cc1c8d89d162cd2f157ac0a7cdddb0e107e3e1644b31f5796e62d9498
BLAKE2b-256 checksum
How to use checksums
6349ef475c674d9104f99c06f463692c3765b38f4d98499aaf464ae5d5b4311b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp314-cp314-macosx_11_0_arm64.whl

Download URL pairlist-1.0.2-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
00198025cd2ed3a8b9c6db84d42fee14539084e82f313e959432f2582b2729ed
BLAKE2b-256 checksum
How to use checksums
520627b4aba99cf98dc795de930c2ec15cc955eff169f824bd54b97951d82edf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp313-cp313-win_amd64.whl

Download URL pairlist-1.0.2-cp313-cp313-win_amd64.whl
Size 23.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
bed68d91cb33e6b3b5e50a9018b6d4998bf9773d02d5403f7972d0e541ec45b3
BLAKE2b-256 checksum
How to use checksums
7c58fcf7e486ebb3fcb6388061a0ba6dfbb8c8cf43a9ae303694e6ebabd69e2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL pairlist-1.0.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 79.3 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
64c8f65ebe35307afdd6cc999d44903844b3e50f0ca40e4c1b5b4563df954b4b
BLAKE2b-256 checksum
How to use checksums
42376252956f3f01645609d2dfb7986b80936eae63bad0dd629c22590980e084
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp313-cp313-macosx_11_0_arm64.whl

Download URL pairlist-1.0.2-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
67f4a1c61769da1bc0c539c09c6efbf257fa1d7eb16dcb7221e8f8b89127f5bd
BLAKE2b-256 checksum
How to use checksums
7b4158e1843f7311ae8c6281298a72fe7f1402c54d0d4ce2313008f6e588067e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp312-cp312-win_amd64.whl

Download URL pairlist-1.0.2-cp312-cp312-win_amd64.whl
Size 23.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6480fabc95d1fc8168c6b242b0c6a5e66726e49804d4dc9c0edf840b47ee2725
BLAKE2b-256 checksum
How to use checksums
6b495ecaab8723d53043c5a1670b0c62727e4ae8469a0b581c2877ebe41d4450
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL pairlist-1.0.2-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
5fd9220da8851c2d6e7b2a3a0289c38570289f12293012f2d9b74bc138983f18
BLAKE2b-256 checksum
How to use checksums
18842f88269e61f8205b92562356389a1ff8fbbd0e289f0e3a2c85f1d4f9741a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL pairlist-1.0.2-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
b99c8625eceab5ed31f688f238b0c2bc118428fe16f3d774103cbb7faba7222f
BLAKE2b-256 checksum
How to use checksums
1f882b1c42b01bae2d1ebc64acb7043b85671ba3efec3672b9fa3d19d7cc3ef0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp311-cp311-win_amd64.whl

Download URL pairlist-1.0.2-cp311-cp311-win_amd64.whl
Size 23.5 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
be7d778428bbf8a18c5bfb6a0fc3558d5a796ef89e1efcf4397b83a90be55423
BLAKE2b-256 checksum
How to use checksums
32bb3508b291834a009977c90be1f1ad15462e4370c655643b95e854cf04d40a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL pairlist-1.0.2-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
cd2cdab03fcebec55d5faddb00d6e69ee765aae05092ec69c27a0fad2c7593af
BLAKE2b-256 checksum
How to use checksums
c29faf39ae51c0665c87e662849657a3df315ce9777d1b1622bc7d92a3f688c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pairlist-1.0.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL pairlist-1.0.2-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
a295ff050ca88134d9b61a166a6815f76d54365fb938d3f912de0b762f091d8b
BLAKE2b-256 checksum
How to use checksums
56674a37434af84fcb4d90a5386049b146f6616a97dc478ec234a7f3ccdc52bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pairlist 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

13 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page