Beispiel #1
0
def test_getitem_bool_TypeError(cls, GMX_REF_FILEPATH):
    slx = cls([True, False, True])

    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        with pytest.raises(TypeError):
            for ts in tng[slx]:
                ts.step
Beispiel #2
0
def test_getitem_bool(arr, cls, GMX_REF_DATA, GMX_REF_FILEPATH):
    slx = cls(arr)
    ref = np.arange(GMX_REF_DATA.length)[slx]

    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        for ref_ts, ts in zip(ref, tng[slx]):
            assert ref_ts == ts.step
Beispiel #3
0
def test_double_iteration(GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        for i, frame in enumerate(tng):
            assert i == frame.step

        for i, frame in enumerate(tng):
            assert i == frame.step
Beispiel #4
0
def test_sliced_iteration(slice_idx, GMX_REF_DATA, GMX_REF_FILEPATH):
    start, stop, step = slice_idx
    ref_steps = np.arange(0, GMX_REF_DATA.length)[start:stop:step]

    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        for ref_ts, ts in zip(ref_steps, tng[start:stop:step]):
            assert ref_ts == ts.step
Beispiel #5
0
def test_first_positions(GMX_REF_DATA, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        first_frame = tng.read().positions
        assert np.array_equal(GMX_REF_DATA.first_frame, first_frame)
Beispiel #6
0
def test_natoms(GMX_REF_DATA, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        assert GMX_REF_DATA.natoms == tng.n_atoms
Beispiel #7
0
def test_load_bad_file(CORRUPT_FILEPATH):
    with pytest.raises(IOError):
        with pytng.TNGFile(CORRUPT_FILEPATH) as tng:
            tng.read()
Beispiel #8
0
def test_getitem_int(idx, GMX_REF_DATA, GMX_REF_FILEPATH):
    indices = np.arange(GMX_REF_DATA.length)
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        ts = tng[idx]
        assert ts.step == indices[idx]
Beispiel #9
0
def test_getitem_multipl_ints(slx, cls, GMX_REF_DATA, GMX_REF_FILEPATH):
    slx = cls(slx)
    indices = np.arange(GMX_REF_DATA.length)
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        for ref_step, ts in zip(indices[slx], tng[slx]):
            assert ref_step == ts.step
Beispiel #10
0
def test_iter(GMX_REF_DATA, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        for i, ts in enumerate(tng):
            assert i == ts.step
Beispiel #11
0
def test_len(GMX_REF_DATA, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        assert GMX_REF_DATA.length == tng.n_frames
        assert GMX_REF_DATA.length == len(tng)
Beispiel #12
0
def test_load_missing_file(MISSING_FILEPATH):
    with pytest.raises(IOError):
        with pytng.TNGFile(MISSING_FILEPATH) as tng:
            tng.read()
Beispiel #13
0
def test_box(GMX_REF_DATA, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        frame = tng.read()
        assert np.array_equal(GMX_REF_DATA.box, frame.box)
Beispiel #14
0
def test_time(GMX_REF_DATA, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        for ref_time, ts in zip(GMX_REF_DATA.time, tng):
            assert ref_time == ts.time
Beispiel #15
0
def test_seek_IOError(idx, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH, 'r') as tng:
        with pytest.raises(IndexError):
            tng[idx]
Beispiel #16
0
def test_last_positions(GMX_REF_DATA, GMX_REF_FILEPATH):
    with pytng.TNGFile(GMX_REF_FILEPATH) as tng:
        tng.seek(tng.n_frames - 1)
        last_frame = tng.read().positions
        assert np.array_equal(GMX_REF_DATA.last_frame, last_frame)