Skip to content

Commit

Permalink
Fix force field parsing with Pint 0.22 or of OpenFF 2.1.0 (#1640)
Browse files Browse the repository at this point in the history
* Minimal fix for #1635 and #1633

* Pluck a test

Co-authored-by: Lily Wang <31115101+lilyminium@users.noreply.github.com>

* Be extra safe testing loading of Sage 2.1

* Update release history

---------

Co-authored-by: Lily Wang <31115101+lilyminium@users.noreply.github.com>
  • Loading branch information
mattwthompson and lilyminium authored Jun 14, 2023
1 parent a53a7e1 commit 369c0eb
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion devtools/conda-envs/beta_rc_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- xmltodict
- python-constraint
- openmm >=7.6
- openff-forcefields
- openff-forcefields >=2023.05.1
- smirnoff99Frosst
- openff-units >=0.2
- openff-utilities >=0.1.5
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/openeye-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- xmltodict
- python-constraint
- openmm >=7.6
- openff-forcefields
- openff-forcefields >=2023.05.1
- smirnoff99Frosst
- openff-amber-ff-ports >=0.0.3
- openff-units >=0.2
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/openeye.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- xmltodict
- python-constraint
- openmm >=7.6
- openff-forcefields
- openff-forcefields >=2023.05.1
- smirnoff99Frosst
- openff-units >=0.2
- openff-utilities >=0.1.5
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/rdkit-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- xmltodict
- python-constraint
- openmm >=7.6
- openff-forcefields
- openff-forcefields >=2023.05.1
- smirnoff99Frosst
- openff-amber-ff-ports >=0.0.3
- openff-units >=0.2
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/rdkit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- xmltodict
- python-constraint
- openmm >=7.6
- openff-forcefields
- openff-forcefields >=2023.05.1
- smirnoff99Frosst
- openff-units >=0.2
- openff-utilities >=0.1.5
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- xmltodict
- python-constraint
- openmm >=7.6
- openff-forcefields
- openff-forcefields >=2023.05.1
- smirnoff99Frosst
- openff-units >=0.2
- openff-utilities >=0.1.5
Expand Down
2 changes: 2 additions & 0 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w

### Bugfixes

- [PR #1640](https://github.com/openforcefield/openff-toolkit/pull/1640): Fixes issue [#1633](https://github.com/openforcefield/openff-toolkit/issues/1633) in which some force field attributes were erroneously parsed as `Quantity` objects and issue [#1635](https://github.com/openforcefield/openff-toolkit/issues/1635) in which OpenFF 2.1.0 ("Sage") could not be loaded with Pint 0.22.

### New features

### Improved documentation and warnings
Expand Down
6 changes: 6 additions & 0 deletions openff/toolkit/tests/test_forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ def test_get_available_force_fields(self):
"openff_unconstrained-1.0.0.offxml",
"openff-1.3.0.offxml",
"openff-2.0.0.offxml",
"openff-2.1.0.offxml",
"ff14sb_off_impropers_0.0.3.offxml",
]

Expand Down Expand Up @@ -1065,6 +1066,11 @@ def test_load_do_not_convert_non_quantity_strings(self):
assert isinstance(parameter.name, str)
assert not isinstance(parameter.name, unit.Quantity)

def test_load_do_not_convert_id_to_quantities(self):
ff = ForceField("openff-2.1.0.offxml")
handler = ff.get_parameter_handler("LibraryCharges")
assert handler.parameters[2].id == "K+"

def test_pickle(self):
"""
Test pickling and unpickling a force field
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/typing/engines/smirnoff/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def _load_smirnoff_data(self, smirnoff_data: dict, allow_cosmetic_attributes=Fal
# Go through the whole SMIRNOFF data structure, trying to convert all strings to Quantity
smirnoff_data = convert_all_strings_to_quantity(
smirnoff_data,
ignore_keys=["smirks", "name"],
ignore_keys=["smirks", "name", "id", "parent_id"],
)

# Go through the subsections, delegating each to the proper ParameterHandler
Expand Down

0 comments on commit 369c0eb

Please sign in to comment.