Repository navigation
Raise ParameterError when writing a topology with missing term types - #1440
Merged
Merged
Conversation
Previously, saving a parmtop/ChamberParm whose bonds, angles, dihedrals, CMAPs, Urey-Bradleys, or impropers had type=None (for example after parmed.openmm.load_topology with constraints=HBonds, where OpenMM removes constrained bonds from the System) failed with AttributeError: 'NoneType' object has no attribute 'used'. Raise a ParameterError naming the offending term instead. Closes ParmEd#1423
swails
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Saving an
AmberParm/ChamberParmwhose valence terms havetype=Nonefailed withAttributeError: 'NoneType' object has no attribute 'used'deep insideremake_parm. This happens afterparmed.openmm.load_topologywhen the OpenMM System drops terms, for exampleconstraints=HBondsremoves constrained bonds fromHarmonicBondForcesoBondobjects exist in the topology but never get aBondType. The reporter of #1423 hit exactly this and could not tell which object was missing parameters.AmberParm._xfer_bond_info,_xfer_angle_info,_xfer_dihedral_info,_xfer_cmap_properties, and theChamberParmUrey-Bradley/improper counterparts now raiseParameterErrornaming the offending term instead of crashing on.used.Test plan
test_write_parm_missing_bond_typenullsbonds[0].typeonala_ala_ala.parm7and assertsParameterErrorwith "no bond type". Fails withAttributeErroron unfixed code, passes after.pytest test/test_parmed_amber.py: 86 passed, 6 skipped (test_optimized_readerdeselected. It needs the uncompiled_rdparmextension and fails identically on master).