Exemplo n.º 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)))
Exemplo n.º 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)))
Exemplo n.º 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)))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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])
Exemplo n.º 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'
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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)
Exemplo n.º 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'
Exemplo n.º 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'
Exemplo n.º 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)))
Exemplo n.º 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)
Exemplo n.º 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'
Exemplo n.º 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'
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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])
Exemplo n.º 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)
Exemplo n.º 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'
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)