Skip to content

Commit 213310f

Browse files
committed
moved rotaxis() tests to tests for mdamath
1 parent ce4f94e commit 213310f

File tree

3 files changed

+64
-47
lines changed

3 files changed

+64
-47
lines changed

package/MDAnalysis/lib/transformations.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
2+
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8
3+
#
4+
# MDAnalysis --- https://www.mdanalysis.org
5+
# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors
6+
# (see the file AUTHORS for the full list of names)
7+
#
8+
# Released under the Lesser GNU Public Licence, v2.1 or any higher version
9+
#
10+
# Please cite your use of MDAnalysis in published work:
11+
#
12+
# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler,
13+
# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein.
14+
# MDAnalysis: A Python package for the rapid analysis of molecular dynamics
15+
# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th
16+
# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy.
17+
# doi: 10.25080/majora-629e541a-00e
18+
#
19+
# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.
20+
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
21+
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
22+
#
23+
124
"""Homogeneous Transformation Matrices and Quaternions --- :mod:`MDAnalysis.lib.transformations`
225
==============================================================================================
326

testsuite/MDAnalysisTests/lib/test_util.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,32 @@ def test_sarrus_det_wrong_shape(self, shape):
529529
with pytest.raises(ValueError):
530530
mdamath.sarrus_det(matrix)
531531

532+
# rotaxis() used to be in lib.transformations but was migrated to mdamath in
533+
# 2.10.0; lib.transformations will be removed in 3.0.
534+
535+
def test_rotaxis_equal_vectors():
536+
a = np.arange(3)
537+
x = mdamath.rotaxis(a, a)
538+
assert_array_equal(x, [1, 0, 0])
539+
540+
541+
def test_rotaxis_different_vectors():
542+
# use random coordinate system
543+
e = np.eye(3)
544+
r = np.array(
545+
[
546+
[0.69884766, 0.59804425, -0.39237102],
547+
[0.18784672, 0.37585347, 0.90744023],
548+
[0.69016342, -0.7078681, 0.15032367],
549+
]
550+
)
551+
re = np.dot(r, e)
552+
553+
for i, j, l in permutations(range(3)):
554+
x = mdamath.rotaxis(re[i], re[j])
555+
# use abs since direction doesn't matter
556+
assert_almost_equal(np.abs(np.dot(x, re[l])), 1)
557+
532558

533559
class TestMakeWhole(object):
534560
"""Set up a simple system:

testsuite/MDAnalysisTests/utils/test_transformations.py

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333

3434
from MDAnalysis.lib import transformations as t
3535

36-
from unittest import TestCase
37-
36+
#------------------------------------------------------------
37+
# DEPRECATION: Remove this file in 3.0 when lib.transformations is removed
38+
#------------------------------------------------------------
3839

3940
"""
4041
Testing transformations is weird because there are 2 versions of many of
@@ -48,6 +49,9 @@
4849
.. versionchanged:: 1.0.0
4950
test_transformations_old_module was removed as core/transformations.py is
5051
gone
52+
53+
.. deprecated:: 2.10.0
54+
will be removed in 3.0.
5155
"""
5256

5357
# tolerance for tests
@@ -59,8 +63,8 @@
5963
# versions from transformations._transformations seem to always shadow
6064
# the Python ones from transformations.transformations.
6165
#
62-
# As a hack, I replaced t._py_* with t.transformations.* so that the
63-
# tests run but they just test the compiled code twice.
66+
# As a hack, I replaced t._py_* with t.transformations.* so that the tests run
67+
# but they just test the compiled code twice. (See PR GH-5062).
6468

6569

6670
@pytest.mark.parametrize(
@@ -420,23 +424,10 @@ def test_superimposition_matrix(f):
420424
M = f(v0, v1)
421425
assert_allclose(v1, np.dot(M, v0), atol=_ATOL)
422426

423-
# scaling kwarg not supported in transformations any more
424-
#
425-
# S = t.scale_matrix(0.45)
426-
# T = t.translation_matrix(np.array([0.2, 0.2, 0.2]) - 0.5)
427-
# M = t.concatenate_matrices(T, R, S)
428-
# v1 = np.dot(M, v0)
429-
# v0[:3] += np.sin(np.linspace(0.0, 1e-9, 300)).reshape(3, -1)
430-
# M = f(v0, v1, scaling=True)
431-
# assert_allclose(v1, np.dot(M, v0), atol=_ATOL)
432-
433-
# M = f(v0, v1, scaling=True, usesvd=False)
434-
# assert_allclose(v1, np.dot(M, v0), atol=_ATOL)
435-
#
436-
# v = np.empty((4, 100, 3), dtype=np.float64)
437-
# v[:, :, 0] = v0
438-
# M = f(v0, v1, scaling=True, usesvd=False)
439-
# assert_allclose(v1, np.dot(M, v[:, :, 0]), atol=_ATOL)
427+
# We used to have tests here that also tested the `scaling=True` kwarg of
428+
# transformations.superimposition_matrix(). This kwarg is no longer
429+
# supported in the transformations package. We don't need it for MDAnalysis
430+
# so we just removed the tests. (See PR GH-5062)
440431

441432

442433
@pytest.mark.parametrize(
@@ -841,32 +832,9 @@ def test_arcball_2(self):
841832
assert_allclose(np.sum(R), 0.2055924)
842833

843834

844-
# rotaxis was an MDA addition
845-
846-
847-
def test_rotaxis_equal_vectors():
848-
a = np.arange(3)
849-
x = t.rotaxis(a, a)
850-
assert_array_equal(x, [1, 0, 0])
851-
852-
853-
def test_rotaxis_different_vectors():
854-
# use random coordinate system
855-
e = np.eye(3)
856-
r = np.array(
857-
[
858-
[0.69884766, 0.59804425, -0.39237102],
859-
[0.18784672, 0.37585347, 0.90744023],
860-
[0.69016342, -0.7078681, 0.15032367],
861-
]
862-
)
863-
re = np.dot(r, e)
864-
865-
for i, j, l in permutations(range(3)):
866-
x = t.rotaxis(re[i], re[j])
867-
# use abs since direction doesn't matter
868-
assert_almost_equal(np.abs(np.dot(x, re[l])), 1)
869-
835+
# rotaxis() was an MDA addition. It was migrated to lib.mdamath in 2.10.0 (and
836+
# its functionality is tested there). A stub with deprecation warning was left
837+
# behin in lib.transformations. All of it will be removed in 3.0.0.
870838

871839
def test_rotaxis_deprecation():
872840
a = np.arange(3)

0 commit comments

Comments
 (0)