Skip to content

Commit

Permalink
add tests for gen_coords box input usual
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrunewald committed Oct 20, 2023
1 parent e87a6c3 commit 663d17d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions polyply/tests/test_gen_coords_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,24 @@ def test_no_positions_generated(tmp_path, monkeypatch):
assert np.all(molecule_out.nodes[node]['position'] ==
molecule_in.nodes[node]['position'])

@pytest.mark.parametrize('box_input, box_ref, density, warning', [
@pytest.mark.parametrize('box_input, box_ref, density, warning, incoords', [
# box from input coordinates
(None, np.array([11.0, 11.0, 11.0]), None, None),
(None, np.array([11.0, 11.0, 11.0]),
None, None, True),
# box from input coordinates overwrites
(np.array([5.0, 5.0, 5.0]), np.array([11.0, 11.0, 11.0]), None, "warn1"),
(np.array([5.0, 5.0, 5.0]), np.array([11.0, 11.0, 11.0]),
None, "warn1", True),
# box from input coordinates and density from CLI
(None, np.array([11.0, 11.0, 11.0]), 1000, "warn2"),
(None, np.array([11.0, 11.0, 11.0]),
1000, "warn2", True),
# box only from CLI
(np.array([8.0, 11.0, 11.0]), np.array([8.0, 11.0, 11.0]),
None, None, False),
# only density
(None, np.array([0.79273, 0.79273, 0.79273]),
1000, None, False),
])
def test_box_input(tmp_path, caplog, box_input, box_ref, density, warning):
def test_box_input(tmp_path, caplog, box_input, box_ref, density, warning, incoords):
"""
Here we test that the correct box is chosen, in case there
are conflicting inputs.
Expand All @@ -69,7 +78,12 @@ def test_box_input(tmp_path, caplog, box_input, box_ref, density, warning):
"provided with starting coordinates."),}

top_file = TEST_DATA / "topology_test/system.top"
pos_file = TEST_DATA / "topology_test/complete.gro"
if incoords:
pos_file = TEST_DATA / "topology_test/complete.gro"
else:
# no input coordiante provided
pos_file = None

out_file = tmp_path / "out.gro"

with caplog.at_level(logging.WARNING):
Expand Down

0 comments on commit 663d17d

Please sign in to comment.