You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The logic I added in vdWHandler.__init__ (#1679, 0.14.2) assumed that the method kwarg was being passed, which usually was not the case. This results in a surprising error, surprising in the sense that I hadn't considered it. Passing the method kwarg through works fine.
This naturally breaks some workflows using the API, which some packages like Evaluator relied on. Loading OFFXMLs seems fine.
To Reproduce
In [1]: fromopenff.toolkit.typing.engines.smirnoff.parametersimportvdWHandlerIn [2]: vdWHandler(version=0.4).periodic_method, vdWHandler(version=0.4).nonperiodic_methodOut[2]: ('cutoff', 'no-cutoff')
In [3]: vdWHandler(version=0.3)
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
CellIn[3], line1---->1vdWHandler(version=0.3)
File~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:2852, invdWHandler.__init__(self, **kwargs)
2843logger.info(
2844'Successfully up-converted vdW section from 0.3 to 0.4. `method="cutoff"` '2845'is now split into `periodic_method="cutoff"` '2846'and `nonperiodic_method="no-cutoff"`.'2847 )
2849else:
2850raiseNotImplementedError(
2851"Failed to up-convert vdW section from 0.3 to 0.4. Did not know "->2852f'how to up-convert `method="{kwargs["method"]}"`.'2853 )
2854super().__init__(**kwargs)
KeyError: 'method'In [4]: vdWHandler(version=0.3, method="cutoff")
Out[4]: <openff.toolkit.typing.engines.smirnoff.parameters.vdWHandlerat0x16f95bf90>
The text was updated successfully, but these errors were encountered:
I'm confused how this is happening; the code looks the same as ElectrostaticsHandler but the behavior is different:
In [11]: ElectrostaticsHandler(version=0.3).versionOut[11]: <Version('0.4')>In [12]: vdWHandler(version=0.3)
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
CellIn[12], line1---->1vdWHandler(version=0.3)
File~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:2852, invdWHandler.__init__(self, **kwargs)
2843logger.info(
2844'Successfully up-converted vdW section from 0.3 to 0.4. `method="cutoff"` '2845'is now split into `periodic_method="cutoff"` '2846'and `nonperiodic_method="no-cutoff"`.'2847 )
2849else:
2850raiseNotImplementedError(
2851"Failed to up-convert vdW section from 0.3 to 0.4. Did not know "->2852f'how to up-convert `method="{kwargs["method"]}"`.'2853 )
2854super().__init__(**kwargs)
KeyError: 'method'
I thought the issue was handling KeyError by passing None to dict.pop, but that's done in both places.
diff --git a/openff/toolkit/typing/engines/smirnoff/parameters.py b/openff/toolkit/typing/engines/smirnoff/parameters.py
index acf2d936..290d1628 100644
--- a/openff/toolkit/typing/engines/smirnoff/parameters.py+++ b/openff/toolkit/typing/engines/smirnoff/parameters.py@@ -2834,7 +2834,7 @@ class vdWHandler(_NonbondedHandler):
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
Describe the bug
The logic I added in
vdWHandler.__init__
(#1679, 0.14.2) assumed that themethod
kwarg was being passed, which usually was not the case. This results in a surprising error, surprising in the sense that I hadn't considered it. Passing themethod
kwarg through works fine.This naturally breaks some workflows using the API, which some packages like Evaluator relied on. Loading OFFXMLs seems fine.
To Reproduce
The text was updated successfully, but these errors were encountered: