From 91120f492c70b7b20269dc0aef771e04bc3b10a2 Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Tue, 8 Aug 2023 10:52:39 -0500 Subject: [PATCH] Do not assume "method" keyword argument specified in `vdWHandler` 0.3 (#1689) * Do not assume "method" keyword argument specified * Update release history --------- Co-authored-by: Jeff Wagner --- docs/releasehistory.md | 3 +++ openff/toolkit/_tests/test_parameters.py | 9 +++++++++ openff/toolkit/typing/engines/smirnoff/parameters.py | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/releasehistory.md b/docs/releasehistory.md index 03012d8e8..097c31dfe 100644 --- a/docs/releasehistory.md +++ b/docs/releasehistory.md @@ -6,12 +6,15 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w * `minor` increments add features but do not break API compatibility * `micro` increments represent bugfix releases or improvements in documentation + ## 0.14.3 ### Bugfixes +- [PR #1689](https://github.com/openforcefield/openff-toolkit/pull/1689): Fixes [#1688](https://github.com/openforcefield/openff-toolkit/issues/1688) in which automatic up-conversion of version 0.3 of `vdWHandler` created via the Python API errored out if `method` was not specified. - [PR #1690](https://github.com/openforcefield/openff-toolkit/pull/1690): Fixes a circular-import bug that occurs when attempting to print a "no cheminformatics toolkits available" warning. + ## 0.14.2 ### Behavior changes diff --git a/openff/toolkit/_tests/test_parameters.py b/openff/toolkit/_tests/test_parameters.py index 813e23f1b..10ca8f4fb 100644 --- a/openff/toolkit/_tests/test_parameters.py +++ b/openff/toolkit/_tests/test_parameters.py @@ -1759,6 +1759,15 @@ def test_upconversion(self): # https://github.com/openforcefield/openff-toolkit/issues/1680 pytest.skip("ParameterAttribute.__delete__ not implemented") + def test_issue_1668(self): + """Reproduce https://github.com/openforcefield/openff-toolkit/issues/1688""" + handler1 = vdWHandler(version=0.3) + handler2 = vdWHandler(version=0.3, method="cutoff") + + assert handler1.version == handler2.version + assert handler1.periodic_method == handler2.periodic_method + assert handler1.nonperiodic_method == handler2.nonperiodic_method + def test_upconversion_unknown_kwarg(self): with pytest.raises( NotImplementedError, diff --git a/openff/toolkit/typing/engines/smirnoff/parameters.py b/openff/toolkit/typing/engines/smirnoff/parameters.py index acf2d936e..290d1628b 100644 --- a/openff/toolkit/typing/engines/smirnoff/parameters.py +++ b/openff/toolkit/typing/engines/smirnoff/parameters.py @@ -2834,7 +2834,7 @@ def __init__(self, **kwargs): logger.info("Attempting to up-convert vdW section from 0.3 to 0.4") # This is the only supported value of "method" is version 0.3 - if kwargs.get("method") == "cutoff": + if kwargs.get("method") in ("cutoff", None): kwargs["periodic_method"] = "cutoff" kwargs["nonperiodic_method"] = "no-cutoff" kwargs["version"] = 0.4