The Open Forcefield Toolkit provides implementations of the SMIRNOFF format, parameterization engine, and other tools. Documentation available at http://open-forcefield-toolkit.readthedocs.io
Setting .scale12, etc. factors to unsupported values raises an inaccurate error message, reporting the supported value and not the specified value.
To Reproduce
In [1]: from openff.toolkit import ForceField
In [2]: sage = ForceField("openff-2.0.0.offxml")
/Users/mattthompson/mambaforge/envs/openff-interchange-env/lib/python3.11/site-packages/smirnoff99frosst/smirnoff99frosst.py:11: UserWarning: Module openff was already imported from None, but /Users/mattthompson/software/openff-toolkit is being added to sys.path
from pkg_resources import resource_filename
In [3]: sage["vdW"].scale12 = 1 / 3
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File ~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:424, in ParameterAttribute._call_converter(self, value, instance)
422 try:
423 # Static function.
--> 424 return self._converter(value)
425 except TypeError:
426 # Instance method.
TypeError: vdWHandler.scale12() missing 2 required positional arguments: 'attrs' and 'new_scale12'
During handling of the above exception, another exception occurred:
SMIRNOFFSpecError Traceback (most recent call last)
Cell In[3], line 1
----> 1 sage["vdW"].scale12 = 1 / 3
File ~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:1168, in _ParameterAttributeHandler.__setattr__(self, key, value)
1163 raise MissingIndexedAttributeError(
1164 f"'{key}' is out of bounds for indexed attribute '{attr_name}'"
1165 )
1167 # Forward the request to the next class in the MRO.
-> 1168 super().__setattr__(key, value)
File ~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:373, in ParameterAttribute.__set__(self, instance, value)
371 def __set__(self, instance, value):
372 # Convert and validate the value.
--> 373 value = self._convert_and_validate(instance, value)
374 setattr(instance, self._name, value)
File ~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:391, in ParameterAttribute._convert_and_validate(self, instance, value)
389 value = self._validate_units(value)
390 # Call the custom converter before setting the value.
--> 391 value = self._call_converter(value, instance)
392 return value
File ~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:427, in ParameterAttribute._call_converter(self, value, instance)
424 return self._converter(value)
425 except TypeError:
426 # Instance method.
--> 427 return self._converter(instance, self, value)
428 return value
File ~/software/openff-toolkit/openff/toolkit/typing/engines/smirnoff/parameters.py:2861, in vdWHandler.scale12(self, attrs, new_scale12)
2858 @scale12.converter
2859 def scale12(self, attrs, new_scale12):
2860 if new_scale12 != 0.0:
-> 2861 raise SMIRNOFFSpecError(
2862 "Current OFF toolkit is unable to handle scale12 values other than 0.0. "
2863 "Specified 1-2 scaling was {}".format(self.scale12)
2864 )
2865 return new_scale12
SMIRNOFFSpecError: Current OFF toolkit is unable to handle scale12 values other than 0.0. Specified 1-2 scaling was 0.0
In [4]: sage["vdW"].scale14 = 4 / 3
# (no output)
Describe the bug
Setting
.scale12
, etc. factors to unsupported values raises an inaccurate error message, reporting the supported value and not the specified value.To Reproduce
https://github.com/openforcefield/openff-interchange/issues/811