Esempio n. 1
0
    def test_join_failures(self):
        dt = load(xtc, top=pdb)
        dt2 = "not a trajectory"

        # Not a trajectory
        with pytest.raises(TypeError) as err:
            _ = dt.join(dt2)
        assert "must be a list of Trajectory" in str(err.value)

        with pytest.raises(TypeError) as err:
            _ = dt.join([dt2])
        assert "only join Trajectory instances" in str(err.value)

        dt2 = load(xtc, top=pdb)
        dt2.top = None  # Remove topology
        with pytest.raises(ValueError) as err:
            _ = dt.join([dt2])
        assert "The topologies of the Trajectories are not" in str(err.value)

        dt2 = load(xtc, top=pdb)
        _ = dt2.unitcell_lengths
        dt2.atom_slice([1, 2, 3], inplace=True)
        with pytest.raises(ValueError) as err:
            _ = dt.join([dt2])
        assert "Number of atoms" in str(err.value)

        dt2 = load(xtc, top=pdb)
        dt2.unitcell_vectors = None  # Remove unitcell
        with pytest.raises(ValueError) as err:
            _ = dt.join([dt2])
        assert "unitcell" in str(err.value)
Esempio n. 2
0
 def test_trajectory_to_mdtraj_with_unitcell_lengths(self):
     dask_traj = load(xtc, top=pdb)
     # Trigger the calculation of unitcell lengths
     _ = dask_traj.unitcell_lengths
     md_traj = md.load(xtc, top=pdb)
     dask_traj.to_mdtraj()
     assert dask_traj == md_traj
Esempio n. 3
0
 def test_wrong_uv_length(self):
     dask_traj = load(xtc, top=pdb)
     with pytest.raises(TypeError) as err:
         dask_traj._calc_length_and_angles([1, 2, 3])
Esempio n. 4
0
 def test_calc_uv_without_ul_or_ua(self):
     dask_traj = load(xtc, top=pdb)
     dask_traj.unitcell_vectors = None
     assert dask_traj._calc_unitcell_vectors() is None
Esempio n. 5
0
 def test_set_xyz_without_top(self):
     dask_traj = load(xtc, top=pdb)
     dask_traj.top = None
     assert dask_traj.top is None
     dask_traj.xyz = np.array([[[1.0, 2.0, 3.0]]], dtype=np.float32)
     assert (dask_traj._xyz == np.array([[[1.0, 2.0, 3.0]]])).all()
Esempio n. 6
0
 def test_trajectory_to_mdtraj(self):
     dask_traj = load(xtc, top=pdb)
     md_traj = md.load(xtc, top=pdb)
     dask_traj.to_mdtraj()
     assert dask_traj == md_traj
Esempio n. 7
0
 def test_hash(self):
     dt = load(xtc, top=pdb)
     dt2 = load(xtc, top=pdb)
     assert dt == dt2  # This will compare hashes
Esempio n. 8
0
 def test_join_discard_overlap(self):
     dt = load(xtc, top=pdb)
     dt2 = load(xtc, top=pdb)
     dt3 = dt.join(dt2[::-1], discard_overlapping_frames=True)
     assert len(dt3) == len(dt) + len(dt2) - 1
Esempio n. 9
0
 def test_join(self):
     dt = load(xtc, top=pdb)
     dt2 = load(xtc, top=pdb)
     dt3 = dt.join(dt2)
     assert len(dt3) == len(dt) + len(dt2)