Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add registered_parameter_handlers property to ForceField #632

Merged
merged 3 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions openforcefield/tests/test_forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,26 @@ def test_nonbonded_method_resolution(self,
forcefield.get_parameter_handler('Electrostatics', {}).method = electrostatics_method
omm_system = forcefield.create_openmm_system(topology)

def test_registered_parameter_handlers(self):
"""Test registered_parameter_handlers property"""
forcefield = ForceField('test_forcefields/smirnoff99Frosst.offxml')
registered_handlers = forcefield.registered_parameter_handlers

expected_handlers = [
'Bonds',
'Angles',
'ProperTorsions',
'ImproperTorsions',
'vdW',
'Electrostatics',
'ToolkitAM1BCC',
]

for expected_handler in expected_handlers:
assert expected_handler in registered_handlers

assert 'LibraryChrages' not in registered_handlers

def test_parameter_handler_lookup(self):
"""Ensure __getitem__ lookups work"""
forcefield = ForceField('test_forcefields/smirnoff99Frosst.offxml')
Expand Down
13 changes: 13 additions & 0 deletions openforcefield/typing/engines/smirnoff/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,19 @@ def register_parameter_io_handler(self, parameter_io_handler):
self._parameter_io_handlers[io_format]))
self._parameter_io_handlers[io_format] = parameter_io_handler

@property
def registered_parameter_handlers(self):
"""
Return the list of registered parameter handlers by name

.. warning :: This API is experimental and subject to change.

Returns
-------
registered_parameter_handlers: iterable of names of ParameterHandler objects in this ForceField

"""
return [*self._parameter_handlers.keys()]

# TODO: Do we want to make this optional?

Expand Down