def test_reduced_box_vectors(): pytest.importorskip("mdtraj") box = np.array([[6.70596027, 0., 0.], [0., 6.70596027, 0.], [3.35299015, 3.35299015, 4.74183893]]) # TODO: replace this with a proper raises test in pytest try: check_reduced_box_vectors(box) except BoxVectorWarning: pass else: raise AssertionError("Box already reduced") if not HAS_OPENMM: pytest.skip() snap = mock_snapshot_with_box_vector(box * nm) reduced_box = reduced_box_vectors(snap).value_in_unit(nm) check_reduced_box_vectors(reduced_box) assert not all(box.flatten() == reduced_box.flatten()) orig_lengths_angles = box_vectors_to_lengths_and_angles(*box) red_lengths_angles = box_vectors_to_lengths_and_angles(*reduced_box) orig_lengths = orig_lengths_angles[:3] red_lengths = red_lengths_angles[:3] npt.assert_allclose(orig_lengths, red_lengths, atol=1e-4)
def test_reduce_trajectory_box_vectors(): box = np.array([[6.70596027, 0., 0.], [0., 6.70596027, 0.], [3.35299015, 3.35299015, 4.74183893]]) snap_1 = mock_snapshot_with_box_vector(box) reduced_box = reduced_box_vectors(snap_1).value_in_unit(nm) snap_2 = mock_snapshot_with_box_vector(reduced_box) traj = paths.Trajectory([snap_1, snap_2]) red_traj = reduce_trajectory_box_vectors(traj) orig_box = traj.box_vectors red_box = red_traj.box_vectors assert not all(orig_box[0].flatten() == red_box[0].flatten()) npt.assert_allclose(red_box[0], red_box[1]) for reduced in red_box: check_reduced_box_vectors(reduced.value_in_unit(nm))
def test_reduce_trajectory_box_vectors(): box = np.array([[ 6.70596027, 0., 0. ], [ 0., 6.70596027, 0. ], [ 3.35299015, 3.35299015, 4.74183893]]) snap_1 = mock_snapshot_with_box_vector(box) reduced_box = reduced_box_vectors(snap_1).value_in_unit(nm) snap_2 = mock_snapshot_with_box_vector(reduced_box) traj = paths.Trajectory([snap_1, snap_2]) red_traj = reduce_trajectory_box_vectors(traj) orig_box = traj.box_vectors red_box = red_traj.box_vectors assert not all(orig_box[0].flatten() == red_box[0].flatten()) npt.assert_allclose(red_box[0], red_box[1]) for reduced in red_box: check_reduced_box_vectors(reduced.value_in_unit(nm))
def test_reduced_box_vectors(): box = np.array([[ 6.70596027, 0., 0. ], [ 0., 6.70596027, 0. ], [ 3.35299015, 3.35299015, 4.74183893]]) # TODO: replace this with a proper raises test in pytest try: check_reduced_box_vectors(box) except BoxVectorWarning: pass else: raise AssertionError("Box already reduced") snap = mock_snapshot_with_box_vector(box * nm) reduced_box = reduced_box_vectors(snap).value_in_unit(nm) check_reduced_box_vectors(reduced_box) assert not all(box.flatten() == reduced_box.flatten()) orig_lengths_angles = box_vectors_to_lengths_and_angles(*box) red_lengths_angles = box_vectors_to_lengths_and_angles(*reduced_box) orig_lengths = orig_lengths_angles[:3] red_lengths = red_lengths_angles[:3] npt.assert_allclose(orig_lengths, red_lengths, atol=1e-4)