-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from wehs7661/test_MTREXEE
Unit tests for MT-REXEE functionalities
- Loading branch information
Showing
3 changed files
with
75 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,62 @@ | ||
#################################################################### | ||
# # | ||
# ensemble_md, # | ||
# a python package for running GROMACS simulation ensembles # | ||
# # | ||
# Written by Wei-Tse Hsu <wehs7661@colorado.edu> # | ||
# Copyright (c) 2022 University of Colorado Boulder # | ||
# # | ||
#################################################################### | ||
""" | ||
Unit tests for the module coordinate_swap.py. | ||
""" | ||
from ensemble_md.utils import coordinate_swap | ||
|
||
def test_get_dimenstion(): | ||
test_file1 = open('ensemble_md/tests/data/coord_swap/input_A.gro', 'r') | ||
test_file2 = open('ensemble_md/tests/data/coord_swap/input_B.gro', 'r') | ||
assert coordinate_swap.get_dimensions(test_file1) == [] | ||
assert coordinate_swap.get_dimensions(test_file2) == [] | ||
|
||
#################################################################### | ||
# # | ||
# ensemble_md, # | ||
# a python package for running GROMACS simulation ensembles # | ||
# # | ||
# Written by Wei-Tse Hsu <wehs7661@colorado.edu> # | ||
# Copyright (c) 2022 University of Colorado Boulder # | ||
# # | ||
#################################################################### | ||
""" | ||
Unit tests for the module test_coordainte_swap.py. | ||
""" | ||
import os | ||
import numpy as np | ||
from ensemble_md.utils import coordinate_swap | ||
|
||
current_path = os.path.dirname(os.path.abspath(__file__)) | ||
input_path = os.path.join(current_path, "data") | ||
|
||
|
||
def test_get_dimensions(): | ||
gro = os.path.join(input_path, 'sys.gro') | ||
f = open(gro, 'r') | ||
lines = f.readlines() | ||
f.close() | ||
vec = coordinate_swap.get_dimensions(lines) | ||
assert vec == [3.32017, 3.32017, 2.34772, 0.00000, 0.00000, 0.00000, 0.00000, 1.66009, 1.66009] | ||
|
||
# Write a flat file with cubic box dimensions | ||
f = open('test.gro', 'w') | ||
f.write('test\n') | ||
f.write(' 1.00000 2.00000 3.00000\n') | ||
f.close() | ||
|
||
f = open('test.gro', 'r') | ||
lines = f.readlines() | ||
f.close() | ||
vec = coordinate_swap.get_dimensions(lines) | ||
assert vec == [1.0, 2.0, 3.0] | ||
|
||
os.remove('test.gro') | ||
|
||
|
||
def test_compute_angle(): | ||
coords_1 = [ | ||
np.array([0.0, 0.0, 0.0]), | ||
np.array([1.0, 0.0, 0.0]), | ||
np.array([0.0, 1.0, 0.0]) | ||
] | ||
coords_2 = coords_1[-1::-1] | ||
coords_3 = [coords_1[1], coords_1[0], coords_1[2]] | ||
|
||
assert np.isclose(coordinate_swap.compute_angle(coords_1), np.pi / 4) | ||
assert np.isclose(coordinate_swap.compute_angle(coords_2), np.pi / 4) | ||
assert np.isclose(coordinate_swap.compute_angle(coords_3), np.pi / 2) | ||
|
||
|
||
def test_get_dimenstion(): | ||
test_file1 = open('ensemble_md/tests/data/coord_swap/input_A.gro', 'r') | ||
test_file2 = open('ensemble_md/tests/data/coord_swap/input_B.gro', 'r') | ||
assert coordinate_swap.get_dimensions(test_file1) == [] | ||
assert coordinate_swap.get_dimensions(test_file2) == [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters