Owns one topology-aware zero-based atom identity. More...
Inherits _ApoObject.
Public Member Functions | |
| None | __init__ (self, CharmmPsf psf, int atom_index) |
| Constructs a reference to one atom in one PSF. | |
| int | getAtomIndex (self) |
| Returns the stored zero-based atom index. | |
| bool | hasSameTopology (self, "AtomReference" other) |
| Tests native PSF object identity. | |
| bool | __eq__ (self, object other) |
| Tests topology identity and atom-index equality. | |
Protected Member Functions | |
| "AtomReference" | _from_handle (cls, ctypes.c_void_p handle) |
| Adopts one newly owned non-NULL C atom-reference handle. | |
Owns one topology-aware zero-based atom identity.
The native object retains shared const ownership of its source PSF and one validated atom index. This Python wrapper owns only the returned C handle; it deliberately does not retain the source CharmmPsf Python wrapper.
Two references have the same topology only when their native PSF shared owners point to the same native CharmmPSF object. Equality additionally requires equal atom indices. Parsing the same PSF file into two independent CharmmPsf objects therefore produces different topologies.
close(), destroy(), context-manager exit, or finalization releases the handle and is idempotent. Methods on a closed reference raise RuntimeError. References are equality-comparable but unordered and unhashable. Construction and queries are host-only and have no coordinate, CUDA, stream, or synchronization state.
Constructs a reference to one atom in one PSF.
| [in] | psf | Live CharmmPsf instance. The Python object is borrowed only during construction; native shared PSF ownership is copied into the new reference. |
| [in] | atom_index | Zero-based atom index representable by signed C int. |
| TypeError | If psf is not a CharmmPsf, if atom_index is not an int, or if atom_index is bool. |
| ValueError | If atom_index does not fit signed C int. |
| RuntimeError | If psf has been closed or if the C ABI reports success but returns a NULL handle. |
| ApoCharmmError | With native status APO_STATUS_NOT_INITIALIZED when the PSF atom count is negative, APO_STATUS_INVALID_ARGUMENT when the native PSF handle or atom index is invalid, or APO_STATUS_RUNTIME_ERROR for allocation or another translated native failure. |
psf as a Python object. | bool apocharmm.atom_reference.AtomReference.__eq__ | ( | self, | |
| object | other | ||
| ) |
Tests topology identity and atom-index equality.
| [in] | other | Object to compare. |
True only for another live AtomReference with the same native PSF object and index. Returns NotImplemented for unrelated Python types so Python can apply normal reflected-comparison behavior. | RuntimeError | If either compared AtomReference has been closed. |
| ApoCharmmError | If either native handle is invalid or another native failure is translated. |
|
protected |
Adopts one newly owned non-NULL C atom-reference handle.
This factory is for wrappers such as AtomSelector.selectAtom() that already own a newly created C handle. It does not repeat PSF or index construction.
| [in] | handle | Newly owned ctypes.c_void_p handle. |
handle without retaining another Python object. | TypeError | If handle is not a ctypes.c_void_p. |
| RuntimeError | If handle is NULL. |
| int apocharmm.atom_reference.AtomReference.getAtomIndex | ( | self | ) |
Returns the stored zero-based atom index.
AtomSelector.selectAtom(). | RuntimeError | If this reference has been closed. |
| ApoCharmmError | If the native handle is invalid or another native failure is translated. |
| bool apocharmm.atom_reference.AtomReference.hasSameTopology | ( | self, | |
| "AtomReference" | other | ||
| ) |
Tests native PSF object identity.
| [in] | other | Live AtomReference to compare. |
True only when both references retain the same native CharmmPSF object. | TypeError | If other is not an AtomReference. |
| RuntimeError | If either reference has been closed. |
| ApoCharmmError | If either native handle is invalid or another native failure is translated. |