Skip to content

Commit

Permalink
Fix #1283 (#1284)
Browse files Browse the repository at this point in the history
* Fix #1283

* Update release notes
  • Loading branch information
SimonBoothroyd authored Apr 25, 2022
1 parent 7d0f029 commit 37d6806
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w

## Current development

## 0.10.6 Bugfix release

### Critical bugfixes

- [PR #1284](https://github.com/openforcefield/openforcefield/pull/1284): Fixes
[Issue #1283](https://github.com/openforcefield/openff-toolkit/issues/1283) - force fields containing `BondCharge` virtual sites cannot be loaded due to an issue with how `outOfPlaneAngle` and `inPlaneAngle` keywords are validated

## 0.10.5 Bugfix release

Expand Down
20 changes: 20 additions & 0 deletions openff/toolkit/tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,26 @@ class TestVirtualSiteHandler:
Test the creation of a VirtualSiteHandler and the implemented VirtualSiteTypes
"""

def test_serialize_roundtrip(self):

force_field = ForceField()

handler = force_field.get_parameter_handler("VirtualSites")
handler.add_parameter(
parameter=VirtualSiteMocking.bond_charge_parameter("[*:1][*:2]")
)
handler.add_parameter(
parameter=VirtualSiteMocking.monovalent_parameter("[*:1][*:2][*:3]")
)
handler.add_parameter(
parameter=VirtualSiteMocking.divalent_parameter("[*:2][*:1][*:3]", "once")
)
handler.add_parameter(
parameter=VirtualSiteMocking.trivalent_parameter("[*:1][*:2][*:3][*:4]")
)

ForceField(force_field.to_string())

@classmethod
def build_force_field(cls, v_site_handler: VirtualSiteHandler) -> ForceField:

Expand Down
6 changes: 6 additions & 0 deletions openff/toolkit/typing/engines/smirnoff/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4795,6 +4795,9 @@ def type_to_parent_index(cls, type_: _VirtualSiteType) -> int:
@outOfPlaneAngle.converter
def outOfPlaneAngle(self, attr, value):

if value == "None":
return None

supports_out_of_plane_angle = self._supports_out_of_plane_angle(self.type)

if not supports_out_of_plane_angle and value is not None:
Expand All @@ -4809,6 +4812,9 @@ def outOfPlaneAngle(self, attr, value):
@inPlaneAngle.converter
def inPlaneAngle(self, attr, value):

if value == "None":
return None

supports_in_plane_angle = self._supports_in_plane_angle(self.type)

if not supports_in_plane_angle and value is not None:
Expand Down

0 comments on commit 37d6806

Please sign in to comment.