示例#1
0
def test_write_coordinates_reshape():
    coordinates = np.random.randn(10,3)
    with LH5TrajectoryFile(temp, 'w') as f:
        f.write(coordinates)

    with LH5TrajectoryFile(temp) as f:
       eq(f.read(), coordinates.reshape(1,10,3), decimal=3)
示例#2
0
def test_topology():
    top = md.load(get_fn('native.pdb')).topology

    with LH5TrajectoryFile(temp, 'w') as f:
        f.topology = top

    with LH5TrajectoryFile(temp) as f:
        assert f.topology == top
示例#3
0
def test_write_multiple():
    coordinates = np.random.randn(4, 10, 3)
    with LH5TrajectoryFile(temp, 'w') as f:
        f.write(coordinates)
        f.write(coordinates)

    with LH5TrajectoryFile(temp) as f:
        eq(f.read(), np.vstack((coordinates, coordinates)), decimal=3)
示例#4
0
def test_read_slice_0():
    coordinates = np.random.randn(4, 10,3)
    with LH5TrajectoryFile(temp, 'w') as f:
        f.write(coordinates)

    with LH5TrajectoryFile(temp) as f:
        eq(f.read(n_frames=2), coordinates[:2], decimal=3)
        eq(f.read(n_frames=2), coordinates[2:4], decimal=3)

    with LH5TrajectoryFile(temp) as f:
        eq(f.read(stride=2), coordinates[::2], decimal=3)

    with LH5TrajectoryFile(temp) as f:
        eq(f.read(stride=2, atom_indices=np.array([0,1])), coordinates[::2, [0,1], :], decimal=3)
示例#5
0
def test_write_coordinates():
    coordinates = np.random.randn(4, 10,3)
    with LH5TrajectoryFile(temp, 'w') as f:
        f.write(coordinates)

    with LH5TrajectoryFile(temp) as f:
        eq(f.read(), coordinates, decimal=3)
        
    with LH5TrajectoryFile(temp) as f:
        f.seek(2)
        eq(f.read(), coordinates[2:], decimal=3)
        f.seek(0)
        eq(f.read(), coordinates[0:], decimal=3)
        f.seek(-1, 2)
        eq(f.read(), coordinates[3:], decimal=3)
示例#6
0
def test_do_overwrite_1():
    with open(temp, 'w') as f:
        f.write('a')

    with pytest.raises(IOError):
        with LH5TrajectoryFile(temp, 'w', force_overwrite=False) as f:
            f.write(np.random.randn(10, 5, 3))
示例#7
0
def test_do_overwrite_0():
    with open(temp, 'w') as f:
        f.write('a')

    with LH5TrajectoryFile(temp, 'w', force_overwrite=True) as f:
        f.write(np.random.randn(10,5,3))