def test_read_ts_coords2(): ''' Test that read_structs(filename) returns a list of 4 lists: of correct length and correct type. ''' filename = '../data/ts_coords.txt' structs = tsp.read_structs(filename) for item in structs: assert len(item) == 38 for item in structs[0]: for subitem in item: assert isinstance(subitem, str) for item in structs[1]: for subitem in item: assert isinstance(subitem, float) for item in structs[2]: for subitem in item: assert isinstance(subitem, float) for item in structs[3]: for subitem in item: assert isinstance(subitem, float)
def test_read_structs_e(): ''' Test that read_structs(filename) returns a list of 4 lists of the expected length Completes unfinished atoms with `nan` ''' expect = 4 filename = '../data/test_structs_e.txt' structs = tsp.read_structs(filename) assert len(structs) == expect for item in structs: assert len(item) == 3 assert len(item[0]) == 2 assert len(item[1]) == 4 assert len(item[2]) == 6 # Check that z[1][1:] are `nan` for value in structs[3][1][1:]: assert np.isnan( value ) # Check that y[1][2:] are `nan` for value in structs[2][1][2:]: assert np.isnan( value ) # Check that x[1][3] are `nan` for value in structs[1][1][3:]: assert np.isnan( value )
def test_read_structs_g(): ''' Test that read_structs(filename) returns a list of 4 lists of the expected length Completes unfinished atoms with `nan` ''' filename = '../data/test_structs_g.txt' try: structs = tsp.read_structs(filename) except Exception as err: assert err.args[0] == 'File termination Error' else: raise Exception('Expected file termination error not raised')
def test_proc_struct_e(): ''' Test that proc_structs(filename) counts structs/atoms ''' filename = '../data/test_structs_e.txt' structs = tsp.read_structs(filename) struct_info = tsp.proc_structs(structs) num_structs = 3 num_atoms = [2, 4, 6] assert struct_info[0] == num_structs assert struct_info[1] == num_atoms
def test_proc_struct_e2(): ''' Test that proc_structs(filename) identifies invalids ''' filename = '../data/test_structs_e.txt' structs = tsp.read_structs(filename) struct_info = tsp.proc_structs(structs) num_inv = 1 list_inv = [1] assert struct_info[2][0] == num_inv assert struct_info[2][1] == list_inv
def test_read_structs_a(): ''' Test that read_structs(filename) returns a list of 4 lists: of the expected length ''' expect = 4 filename = '../data/test_structs_a.txt' structs = tsp.read_structs(filename) assert len(structs) == expect for item in structs: assert len(item) == 1 assert len(item[0]) == 2
def test_read_ts_coords(): ''' Test that read_structs(filename) returns a list of 4 lists(of lists) ''' expect = 4 filename = '../data/ts_coords.txt' structs = tsp.read_structs(filename) assert len(structs) == expect for item in structs: assert isinstance(item, list) for subitem in item: assert isinstance(subitem, list)
def test_proc_ts_coords(): ''' Test that proc_structs(filename) counts structs/atoms ''' filename = '../data/ts_coords.txt' structs = tsp.read_structs(filename) struct_info = tsp.proc_structs(structs) num_structs = 38 num_atoms = [ 35, 44, 38, 44, 50, 38, 50, 32, 41, 35, 41, 38, 41, 47, 47, 41, 35, 41, 41, 41, 41, 32, 50, 41, 47, 32, 47, 44, 38, 41, 47, 41, 44, 44, 38, 44, 38, 44 ] assert struct_info[0] == num_structs assert struct_info[1] == num_atoms