openforcefield / openff-toolkit

The Open Forcefield Toolkit provides implementations of the SMIRNOFF format, parameterization engine, and other tools. Documentation available at http://open-forcefield-toolkit.readthedocs.io
http://openforcefield.org
MIT License
318 stars 92 forks source link

Virtual site parameter lookups don't support safe indexing #1893

Closed mattwthompson closed 4 months ago

mattwthompson commented 4 months ago

In #1861 while disallowing SMIRKS-based lookups I also removed support for int-based indexing into the parameter list, which I don't think should be considered unsafe.

In [1]: from openff.toolkit import ForceField

In [2]: ForceField("opc.offxml")['VirtualSites'].parameters[0]
/Users/mattthompson/micromamba/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-interchange is being added to sys.path
  from pkg_resources import resource_filename
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 ForceField("opc.offxml")['VirtualSites'].parameters[0]

File ~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/toolkit/typing/engines/smirnoff/parameters.py:1614, in VirtualSiteParameterList.__getitem__(self, val)
   1613 def __getitem__(self, val):
-> 1614     raise NotImplementedError(
   1615         "VirtualSiteHandler does not support __getitem__ lookups due to the "
   1616         "number of values required to uniquely identify a specific parameter."
   1617     )

NotImplementedError: VirtualSiteHandler does not support __getitem__ lookups due to the number of values required to uniquely identify a specific parameter.
mattwthompson commented 4 months ago

Probably in 0.16.2