httk.atomistic.symmetry.comparison_cache

Bounded, identity-based preparation caches for approximate comparisons.

Classes

StructureComparisonCache

Cache reusable approximate-comparison preparation for one caller scope.

Module Contents

class httk.atomistic.symmetry.comparison_cache.StructureComparisonCache(*, max_structures=256, max_geometries=1024, max_geometry_bytes=16 * 1024 * 1024)[source]

Cache reusable approximate-comparison preparation for one caller scope.

Entries are keyed by object identity and retain strong references to their source objects. This avoids relying on the unhashable exact structure models and prevents object-id reuse while an entry is live. The cache stores derived structures, normalizer-image tuples and prepared NumPy orbit arrays. Cell-pair metrics remain per-comparison data. Normalizer images have a separate capacity so preparing them does not evict cached canonical structures.

Parameters:
  • max_structures (int) – Maximum number of structure/template conversion and canonicalization entries retained together, and independently the maximum number of normalizer-image tuples retained.

  • max_geometries (int) – Maximum number of NumPy Cartesian-orbit entries retained.

  • max_geometry_bytes (int) – Maximum combined array payload in the geometry cache, excluding Python objects and exact source structures. An oversized geometry is used without caching or evicting other entries.

Raises:

ValueError – If any limit is not a positive integer.

clear()[source]

Discard all cached derived structures and geometry arrays.