Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier indexing into collections #968

Open
mattwthompson opened this issue Apr 22, 2024 · 0 comments · Fixed by #990
Open

Easier indexing into collections #968

mattwthompson opened this issue Apr 22, 2024 · 0 comments · Fixed by #990

Comments

@mattwthompson
Copy link
Member

Description

In [17]: out = ForceField("openff-2.1.0.offxml").create_interchange(
    ...:     Molecule.from_smiles("CCO").to_topology()
    ...: )

Indexing into a collection to get (physics) parameters with known atom indices requires creating a new instance of a key:

In [18]: out["Bonds"].potentials[out["Bonds"].key_map[BondKey(atom_indices=(0, 1))]]
Out[18]: Potential(parameters={'k': <Quantity(419.986927, 'kilocalorie / angstrom ** 2 / mole')>, 'length': <Quantity(1.52794022, 'angstrom')>}, map_key=None)

It'd be a little more convenient to, at least in simpler cases, allow lookup just by atom indices. That's really all of the information that's stored in some of those key objects:

In [19]: out["Bonds"].potentials[(0, 1)]

I'm not sure if this should return a PotentialKey or Potential

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant