Duplicate check
Forward compute, locate, and ghost_cells always enforce a private
backend-safety floor before native insertion. The standalone helpers documented
below remain explicit user-threshold diagnostics; the forward
duplicate_check, duplicate_threshold, and duplicate_wrap arguments cannot
weaken mandatory safety.
pyvoro2.duplicates
Duplicate / near-duplicate point detection.
Voro++ contains an internal "duplicate" safeguard that can terminate the
process (via exit(1)) if it detects two points closer than an absolute
threshold (~1e-5 in container distance units).
This module provides the public diagnostic helper. Native-facing operations add an independent mandatory safety floor in the private generator-preparation layer, so turning an optional diagnostic off never weakens backend safety.
Expected complexity is O(n) for typical inputs.
DuplicateError
Bases: ValueError
Raised when near-duplicate points are detected.
duplicate_check(points, *, threshold=1e-05, domain=None, wrap=True, mode='raise', max_pairs=10)
Detect point pairs closer than an absolute threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
Any
|
Array-like of shape (n, 3). |
required |
threshold
|
float
|
Absolute distance threshold. The default (1e-5) matches the public strict-distance diagnostic threshold. |
1e-05
|
domain
|
Domain | None
|
Optional domain. If provided and |
None
|
wrap
|
bool
|
Whether to remap points into the primary domain when |
True
|
mode
|
Literal['raise', 'warn', 'return']
|
Behavior when duplicates are found:
- 'raise' (default): raise :class: |
'raise'
|
max_pairs
|
int
|
Maximum number of pairs to include in the report. |
10
|
Returns:
| Type | Description |
|---|---|
tuple[DuplicatePair, ...]
|
Tuple of DuplicatePair records (possibly empty). |
:::