Skip to content

Commit

Permalink
added the deleted statements
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya292002 committed Jan 24, 2024
1 parent cb0391c commit 911c808
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
5 changes: 0 additions & 5 deletions package/MDAnalysis/visualization/streamlines_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,10 @@ def point_in_cube(array_point_coordinates, list_cube_vertices, cube_centroid):
cube_half_side_length = scipy.spatial.distance.pdist(array_cube_vertices, 'euclidean').min() / 2.0
array_cube_vertex_distances_from_centroid = scipy.spatial.distance.cdist(array_cube_vertices,
cube_centroid[np.newaxis, :])



np.testing.assert_allclose(array_cube_vertex_distances_from_centroid.min(),

Check warning on line 248 in package/MDAnalysis/visualization/streamlines_3D.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/visualization/streamlines_3D.py#L248

Added line #L248 was not covered by tests
array_cube_vertex_distances_from_centroid.max(), rtol=0, atol=1.5*(1e-4),
err_msg="not all cube vertex to centroid distances are the same, "
"so not a true cube")



absolute_delta_coords = np.absolute(np.subtract(array_point_coordinates, cube_centroid))
absolute_delta_x_coords = absolute_delta_coords[..., 0]
Expand Down
39 changes: 28 additions & 11 deletions testsuite/MDAnalysisTests/analysis/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import pytest
from MDAnalysis import SelectionError, SelectionWarning
from MDAnalysisTests import executable_not_found
import numpy as np
from MDAnalysisTests.datafiles import (PSF, DCD, CRD, FASTA, ALIGN_BOUND,
ALIGN_UNBOUND, PDB_helix)
from numpy.testing import (
Expand Down Expand Up @@ -201,8 +200,6 @@ def test_rmsd(self, universe, reference):
first_frame = bb.positions
universe.trajectory[-1]
last_frame = bb.positions
# assert_almost_equal(rms.rmsd(first_frame, first_frame), 0.0, 5,
# err_msg="error: rmsd(X,X) should be 0")

assert_allclose(rms.rmsd(first_frame, first_frame), 0.0, rtol=0, atol=1.5*1e-5,
err_msg="error: rmsd(X,X) should be 0")
Expand All @@ -212,17 +209,14 @@ def test_rmsd(self, universe, reference):
# 9th decimal have been observed (see Issue 57 comment #1) so we relax
# the test to 6 decimals.
rmsd = rms.rmsd(first_frame, last_frame, superposition=True)
# assert_almost_equal(
# rms.rmsd(last_frame, first_frame, superposition=True), rmsd, 6,
# err_msg="error: rmsd() is not symmetric")

assert_allclose(
rms.rmsd(last_frame, first_frame, superposition=True), rmsd, rtol=0, atol=1.5*1e-6,
err_msg="error: rmsd() is not symmetric")


assert_allclose(rmsd, 6.820321761927005, rtol=0, atol=1.5*(1e-5),
err_msg="RMSD calculation between 1st and last AdK frame gave wrong answer")

# test masses as weights
last_atoms_weight = universe.atoms.masses
A = universe.trajectory[0]
Expand Down Expand Up @@ -366,26 +360,49 @@ def test_AlignTraj_in_memory(self, universe, reference, tmpdir):

# check in memory trajectory
self._assert_rmsd(reference, universe, 0, 6.929083044751061)
def _assert_rmsd(self, reference, fitted, frame, desired, weights=None):
self._assert_rmsd(reference, universe, -1, 0.0)

def _assert_rmsd(self, reference, fitted, frame, desired, weights=None):
fitted.trajectory[frame]
rmsd = rms.rmsd(reference.atoms.positions, fitted.atoms.positions,
superposition=True)
np.testing.assert_allclose(rmsd, desired, rtol=0, atol=1.5*(1e-5),
err_msg="frame {0:d} of fit does not have "
"expected RMSD".format(frame))


def test_alignto_checks_selections(self, universe, reference):
"""Testing that alignto() fails if selections do not
match (Issue 143)"""
u = universe

def different_size():
a = u.atoms[10:100]
b = u.atoms[10:101]
return align.alignto(a, b)

with pytest.raises(SelectionError):
different_size()

def different_atoms():
a = u.atoms[10:20]
b = u.atoms[10:17] + u.atoms[18:21]
return align.alignto(a, b)

with pytest.raises(SelectionError):
different_atoms()

def test_alignto_partial_universe(self, universe, reference):
u_bound = mda.Universe(ALIGN_BOUND)
u_free = mda.Universe(ALIGN_UNBOUND)
selection = 'segid B'

segB_bound = u_bound.select_atoms(selection)
segB_free = u_free.select_atoms(selection)
segB_free.translate(segB_bound.centroid() - segB_free.centroid())

align.alignto(u_free, u_bound, select=selection)
np.testing.assert_allclose(segB_bound.positions, segB_free.positions,
rtol=0, atol=1.5*(1e-3))
assert_array_almost_equal(segB_bound.positions, segB_free.positions,
decimal=3)



Expand Down

0 comments on commit 911c808

Please sign in to comment.