コード例 #1
0
 def test_main_k_and_f(self):
     """Tests main using k and f"""
     kwargs = {'two_line_test': False, 'i': ['../test_data/as.out'], 'k': [2], 'f': [1, 4], 'q': ['absent'], 'r': [0], 'o': ['lmax.out'], 'quiet': False, 'plots': False, 'two_line_threshold': [0.55], 's': [], 'hist_bins': [10], 'p': [0]}
     lmax.main(**kwargs)
     results = open('lmax.out', 'r').readlines()[1].split(' + ')
     assert float(results[0].replace('The optimized reaction coordinate (with CVs indexed from 1) is: ', '')) == pytest.approx(5.47, 1E-2)
     assert float(results[1].replace('*CV1', '')) == pytest.approx(-22.116, 1E-2)
     assert float(results[2].replace('*CV4', '')) == pytest.approx(5.483, 1E-2)
     assert len(results) == 3
コード例 #2
0
 def test_main_k_f_and_q(self):
     """Tests main using k, f, and q"""
     kwargs = {'two_line_test': False, 'i': ['../test_data/as.out'], 'k': [2], 'f': [1, 4], 'q': ['present'], 'r': [0], 'o': ['lmax.out'], 'quiet': True, 'plots': False, 'two_line_threshold': [0.55], 's': [], 'hist_bins': [10], 'p': [0]}
     with pytest.raises(RuntimeError):   # this as.out file has an uneven number of CVs
         lmax.main(**kwargs)
     kwargs = {'two_line_test': False, 'i': ['as.out'], 'k': [2], 'f': [1, 2], 'q': ['present'], 'r': [0], 'o': ['lmax.out'], 'quiet': True, 'plots': False, 'two_line_threshold': [0.55], 's': [], 'hist_bins': [10], 'p': [0]}
     shutil.copy('../test_data/as.out', 'as_temp.out')   # need to make a new as.out file with an even number of CVs
     open('as.out', 'w').close()
     for line in open('as_temp.out', 'r').readlines():
         line = line.strip('\n') + ' 0.01\n'
         open('as.out', 'a').write(line)
     lmax.main(**kwargs)
     results = open('lmax.out', 'r').readlines()[1].split(' + ')
     assert float(results[0].replace('The optimized reaction coordinate (with CVs indexed from 1) is: ', '')) == pytest.approx(-0.654, 1E-2)
     assert float(results[1].replace('*CV1', '')) == pytest.approx(-6.279, 1E-2)
     assert float(results[2].replace('*CV2', '')) == pytest.approx(11.096, 1E-2)
     assert len(results) == 3
コード例 #3
0
 def test_main_improper_input(self):
     """Tests main using an input file that does exist, but is improperly formatted"""
     kwargs = {'two_line_test': True, 'i': ['../test_data/test.rst7'], 'k': [0], 'f': [], 'q': ['absent'], 'r': [0], 'o': ['lmax.out'], 'quiet': True, 'plots': False, 'two_line_threshold': [0.55], 's': [], 'hist_bins': [10], 'p': [0]}
     with pytest.raises(RuntimeError):
         lmax.main(**kwargs)
コード例 #4
0
 def test_main_non_existent_input(self):
     """Tests main using an input file name that does not exist"""
     kwargs = {'two_line_test': True, 'i': ['definitely_not_a_real_file_who_would_name_a_file_this.txt'], 'k': [0], 'f': [], 'q': ['absent'], 'r': [0], 'o': ['lmax.out'], 'quiet': True, 'plots': False, 'two_line_threshold': [0.55], 's': [], 'hist_bins': [10], 'p': [0]}
     with pytest.raises(FileNotFoundError):
         lmax.main(**kwargs)