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