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 ofClusterwas a copy of the one forManyBodyNeighborList. Resolves all eight todo markers insrc/. - Remove unreachable code: the stream operator for
Orbit, the subtraction operator forLatticeSite, one constructor ofOrbitList, and theget_orbit_listbinding. Six members ofOrbitListthat are used only internally become private. - Move the string representation of
Clustertoicet.core.cluster, following the pattern already used foricet.core.orbit. The output is unchanged. - Split
OrbitList::createOrbitinto three named helpers, one per stage of the algorithm, and replace exception-driven control flow with non-throwing lookups inOrbitListandSymmetry.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.