Move `FixSymmetry` to constraints module and fix the `.todict()` method
This MR moves FixSymmetry
to the ase.constraints
module.
All of the constraints are in ase.constraints
except for FixSymmetry
. This imposes some significant problems, in addition to just being annoying. Most notably, the FixSymmetry
class cannot be used in an optimization with a Trajectory
written to the filesystem because the dict2constraints
function can't resolve the FixSymmetry
class from the ase.constraints
module since it does not exist there, as exemplified below:
__all__ = [
'FixCartesian', 'FixBondLength', 'FixedMode',
'FixAtoms', 'FixScaled', 'FixCom', 'FixSubsetCom', 'FixedPlane',
'FixConstraint', 'FixedLine', 'FixBondLengths', 'FixLinearTriatomic',
'FixInternals', 'Hookean', 'ExternalForce', 'MirrorForce', 'MirrorTorque',
"FixScaledParametricRelations", "FixCartesianParametricRelations"]
def dict2constraint(dct):
if dct['name'] not in __all__:
raise ValueError
return globals()[dct['name']](**dct['kwargs'])
Comically, FixSymmetry
was already referenced in all the usual constraints places. For instance, ase/test/constraints/test_fix_symmetry.py
is the test for FixSymmetry
, and doc/ase/constraints.rst
direcrtly mentions FixSymmetry
.
Edit: This also would close #1397 (closed).
Checklist
-
I am familiar with ASE's contribution guidelines. -
Doc strings in code changed in this MR are up to date. -
Unit tests have been added for new or changed code. -
Issue is resolved via "closes #XXXX" if applicable.
Edited by Andrew Rosen