Beispiel #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)))
Beispiel #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)))
Beispiel #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)))
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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])
Beispiel #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'
Beispiel #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])
Beispiel #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])
Beispiel #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)
Beispiel #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'
Beispiel #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'
Beispiel #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)))
Beispiel #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)
Beispiel #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'
Beispiel #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'
Beispiel #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)
Beispiel #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)
Beispiel #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])
Beispiel #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)
Beispiel #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'
Beispiel #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)
Beispiel #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)
Beispiel #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)