예제 #1
0
def test_read_auto_col_one_line(tmpdir):
    he_col = (' He    2.0    0.00000000    0.00000000    0.00000000' +
              '    4.00260325\n')
    f = ef.tmpf(tmpdir, he_col)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == ['He'])
    assert np.allclose(xyz, np.zeros((1, 3)))
예제 #2
0
def test_read_auto_col_one_line(tmpdir):
    he_col = (' He    2.0    0.00000000    0.00000000    0.00000000' +
              '    4.00260325\n')
    f = ef.tmpf(tmpdir, he_col)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == ['He'])
    assert np.allclose(xyz, np.zeros((1, 3)))
예제 #3
0
def test_read_auto_zmt_one_line(tmpdir):
    f = ef.tmpf(tmpdir, 'He\n')
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == ['He'])
    assert np.allclose(xyz, np.zeros((1, 3)))
예제 #4
0
def test_read_auto_only_comment(tmpdir):
    f = ef.tmpf(tmpdir, 'comment line\n')
    with pytest.raises(IOError, match=r'cannot have comment with single .*'):
        elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
예제 #5
0
def test_read_auto_only_comment(tmpdir):
    f = ef.tmpf(tmpdir, 'comment line\n')
    with pytest.raises(IOError, match=r'cannot have comment with single .*'):
        elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
예제 #6
0
def test_read_auto_traj(tmpdir):
    f = ef.tmpf(tmpdir, ef.traj_time)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == 5*['X'])
    assert np.allclose(xyz, eg.ch4[1], atol=1e-4)
예제 #7
0
def test_read_auto_zmt(tmpdir):
    f = ef.tmpf(tmpdir, ef.zmt_nocom)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4_zmt[1], atol=1e-6)
예제 #8
0
def test_read_auto_col(tmpdir):
    f = ef.tmpf(tmpdir, ef.col_nocom)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4[1])
예제 #9
0
def test_read_auto_traj_one_line_comment(tmpdir):
    f = ef.tmpf(tmpdir, ef.traj_com)
    elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
    assert np.all(elem == 5*['X'])
    assert np.allclose(xyz, eg.ch4[1], atol=1e-4)
    assert com == 'comment line'
예제 #10
0
def test_read_auto_gdat(tmpdir):
    f = ef.tmpf(tmpdir, ef.gdat_bohr)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4[1])
예제 #11
0
def test_read_auto_col(tmpdir):
    f = ef.tmpf(tmpdir, ef.col_nocom)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4[1])
예제 #12
0
def test_read_auto_unrecognized_one_line_comment(tmpdir):
    f = ef.tmpf(tmpdir, 'comment line\n123 abc 456 def\n')
    with pytest.raises(IOError, match=r'single line input in unrecognized .*'):
        elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
예제 #13
0
def test_read_auto_traj_one_line_comment(tmpdir):
    f = ef.tmpf(tmpdir, ef.traj_com)
    elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
    assert np.all(elem == 5 * ['X'])
    assert np.allclose(xyz, eg.ch4[1], atol=1e-4)
    assert com == 'comment line'
예제 #14
0
def test_read_auto_zmt_one_line_comment(tmpdir):
    f = ef.tmpf(tmpdir, 'comment line\nHe\n')
    elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
    assert np.all(elem == ['He'])
    assert np.allclose(xyz, np.zeros((1, 3)))
    assert com == 'comment line'
예제 #15
0
def test_read_auto_zmt_one_line(tmpdir):
    f = ef.tmpf(tmpdir, 'He\n')
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == ['He'])
    assert np.allclose(xyz, np.zeros((1, 3)))
예제 #16
0
def test_read_auto_zmt(tmpdir):
    f = ef.tmpf(tmpdir, ef.zmt_nocom)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4_zmt[1], atol=1e-6)
예제 #17
0
def test_read_auto_zmt_one_line_comment(tmpdir):
    f = ef.tmpf(tmpdir, 'comment line\nHe\n')
    elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
    assert np.all(elem == ['He'])
    assert np.allclose(xyz, np.zeros((1, 3)))
    assert com == 'comment line'
예제 #18
0
def test_read_auto_zmt_comment(tmpdir):
    f = ef.tmpf(tmpdir, ef.zmt_com)
    elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4_zmt[1], atol=1e-6)
    assert com == 'comment line'
예제 #19
0
def test_read_auto_unrecognized_one_line_comment(tmpdir):
    f = ef.tmpf(tmpdir, 'comment line\n123 abc 456 def\n')
    with pytest.raises(IOError, match=r'single line input in unrecognized .*'):
        elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
예제 #20
0
def test_read_auto_traj(tmpdir):
    f = ef.tmpf(tmpdir, ef.traj_time)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == 5 * ['X'])
    assert np.allclose(xyz, eg.ch4[1], atol=1e-4)
예제 #21
0
def test_read_auto_gdat(tmpdir):
    f = ef.tmpf(tmpdir, ef.gdat_bohr)
    elem, xyz, vec, com = fileio.read_auto(f)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4[1])
예제 #22
0
def test_read_auto_unrecognized_multi_lines(tmpdir):
    f = ef.tmpf(tmpdir, 'abc 123 def 456\nabc def 123 456\n123 456 abc def\n')
    with pytest.raises(IOError, match=r'unrecognized file format'):
        elem, xyz, vec, com = fileio.read_auto(f)
예제 #23
0
def test_read_auto_zmt_comment(tmpdir):
    f = ef.tmpf(tmpdir, ef.zmt_com)
    elem, xyz, vec, com = fileio.read_auto(f, hascom=True)
    assert np.all(elem == eg.ch4[0])
    assert np.allclose(xyz, eg.ch4_zmt[1], atol=1e-6)
    assert com == 'comment line'
예제 #24
0
def test_read_auto_end_of_file(tmpdir):
    f = ef.tmpf(tmpdir, '')
    with pytest.raises(IOError, match=r'end of file'):
        elem, xyz, vec, com = fileio.read_auto(f)
예제 #25
0
def test_read_auto_unrecognized_multi_lines(tmpdir):
    f = ef.tmpf(tmpdir, 'abc 123 def 456\nabc def 123 456\n123 456 abc def\n')
    with pytest.raises(IOError, match=r'unrecognized file format'):
        elem, xyz, vec, com = fileio.read_auto(f)
예제 #26
0
def test_read_auto_end_of_file(tmpdir):
    f = ef.tmpf(tmpdir, '')
    with pytest.raises(IOError, match=r'end of file'):
        elem, xyz, vec, com = fileio.read_auto(f)