Skip to content

Commit

Permalink
hmmm
Browse files Browse the repository at this point in the history
  • Loading branch information
hmacdope committed Oct 24, 2024
1 parent 8cae6f8 commit 50efeb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package/MDAnalysis/lib/_distopia.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def calc_bond_distance_ortho(
distopia.calc_bonds_ortho(

Check warning on line 66 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L66

Added line #L66 was not covered by tests
coords1, coords2, box[:3], results=results
)
# upcast is currently required, change for 3.0, see #3927



def calc_bond_distance(
Expand All @@ -75,7 +75,6 @@ def calc_bond_distance(
distopia.calc_bonds_no_box(

Check warning on line 75 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L75

Added line #L75 was not covered by tests
coords1, coords2, results=results
)
# upcast is currently required, change for 3.0, see #3927


def calc_bond_distance_triclinic(
Expand All @@ -89,6 +88,7 @@ def calc_angle(
) -> None:
distopia.calc_angles_no_box(coords1, coords2, coords3, results=results)

Check warning on line 89 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L89

Added line #L89 was not covered by tests


def calc_angle_ortho(
coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, box: np.ndarray, results: np.ndarray
) -> None:
Expand Down Expand Up @@ -122,6 +122,7 @@ def calc_distance_array(
) -> None:
distopia.calc_distance_array_no_box(coords1, coords2, results=results)

Check warning on line 123 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L123

Added line #L123 was not covered by tests


def calc_distance_array_ortho(
coords1: np.ndarray, coords2: np.ndarray, box: np.ndarray, results: np.ndarray
) -> None:
Expand Down
15 changes: 15 additions & 0 deletions testsuite/MDAnalysisTests/lib/test_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ def test_outarray(self, DCD_Universe, backend):
natoms = len(U.atoms)
d = np.zeros((natoms, natoms), np.float64)
distances.distance_array(x0, x1, result=d, backend=backend)
print("AFTER")
print(d)
assert_equal(d.shape, (natoms, natoms), "wrong shape, should be"
" (Natoms,Natoms) entries")
assert_almost_equal(d.min(), 0.11981228170520701, self.prec,
Expand Down Expand Up @@ -937,6 +939,19 @@ def test_bonds(self, box, backend, dtype, pos, request):
assert_almost_equal(dists_pbc[3], 3.46410072, self.prec,
err_msg="PBC check #w with box")

@pytest.mark.parametrize("dtype", (np.float32, np.float64))
@pytest.mark.parametrize("backend", distopia_conditional_backend())
def test_results_inplace_all_backends(self, backend, dtype,):
N = 10
c0 = np.ones(3 * N, dtype=dtype).reshape(N, 3) * 2
c1 = np.ones(3 * N, dtype=dtype).reshape(N, 3) * 3

result = np.zeros(N, dtype=np.float64)
distances.calc_bonds(c0, c1, result=result, backend=backend)
expected = np.ones(N, dtype=dtype) * 3**(1/2)
# test the result array is updated in place
assert_almost_equal(result, expected, self.prec, err_msg="calc_bonds inplace failed")

@pytest.mark.parametrize("backend", distopia_conditional_backend())
def test_bonds_badbox(self, positions, backend):
a, b, c, d = positions
Expand Down

0 comments on commit 50efeb9

Please sign in to comment.