Improve clarity and documentation of the C++ core

Reviews the C++ core for clarity, documentation, and dead code.

  • Correct docstrings that described code other than their own. The docstring of ManyBodyNeighborList::combineToHigherOrder described a traversal that belongs to OrbitList, and the pybind docstring of Cluster was a copy of the one for ManyBodyNeighborList. Resolves all eight todo markers in src/.
  • Remove unreachable code: the stream operator for Orbit, the subtraction operator for LatticeSite, one constructor of OrbitList, and the get_orbit_list binding. Six members of OrbitList that are used only internally become private.
  • Move the string representation of Cluster to icet.core.cluster, following the pattern already used for icet.core.orbit. The output is unchanged.
  • Split OrbitList::createOrbit into three named helpers, one per stage of the algorithm, and replace exception-driven control flow with non-throwing lookups in OrbitList and Symmetry.hpp.
  • Factor out the validation repeated across the three public methods of ClusterExpansionCalculator, and simplify several conditions elsewhere.
  • Clean up the pybind interface: add the missing class and method docstrings, stop suppressing the argument signatures in help(), use builtin generics, and refer to each class by the name it is registered under.

Executable statements in src/ decrease by 41 lines, while comments and docstrings increase by 255. The aim of the change is clarity rather than size.

Behavior is unchanged and the 832 unit tests pass. Orbit list construction and the cluster vector hot paths were benchmarked over three alternating rounds against a build of master, with no regression.

One point for review. OrbitList::appendOrbitFromRows, formerly addColumnsFromMatrixOfEquivalentSites, validates one translation of a cluster but appends another, the lowest one. Adding a check that the lowest translation is itself anchored in the unit cell at the origin makes the test suite fail, so the two are often different translations. The behavior is preserved and now documented.

Edited by Paul Erhart

Merge request reports

Loading
Loading