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

preserve meta when converting block to molecule #245

Merged
merged 6 commits into from
Apr 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added test for to_molecule
  • Loading branch information
fgrunewald committed Apr 12, 2020
commit 6fe70941647c27474184da0b540da839af8ebed7
27 changes: 27 additions & 0 deletions vermouth/tests/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import pytest
import vermouth
import vermouth.molecule
import vermouth.forcefield
from vermouth.molecule import Interaction, Molecule

from .molecule_strategies import random_molecule, random_block, random_link
Expand Down Expand Up @@ -1243,3 +1244,29 @@ def test_str_method(mol, moltype):
assert '{} {}'.format(len(interactions), itype) in found
else:
assert '{} {}'.format(0, itype) not in found

def test_to_molecule():
"""
Test if the to molecule function gives
expected results.
"""
force_field = vermouth.forcefield.ForceField("test")
test_block = vermouth.molecule.Block()
test_block.add_edges_from([('A','B'), ('B','C')])
fgrunewald marked this conversation as resolved.
Show resolved Hide resolved
test_block.interactions["bonds"] = [
Interaction(atoms=('A', 'B'),
parameters=['a', '0.2', '200'],
meta={'a': 0}),
Interaction(atoms=('B', 'C'),
parameters=['a', '0.1', '300'],
meta={'b': 1}),]

molecule = test_block.to_molecule()

ref_bonds = [ Interaction(atoms=(0, 1),
parameters=['a', '0.2', '200'],
meta={'a': 0}),
Interaction(atoms=(1, 2),
parameters=['a', '0.1', '300'],
meta={'b': 1}),]
fgrunewald marked this conversation as resolved.
Show resolved Hide resolved
assert ref_bonds == molecule.interactions['bonds']