From 51649adc6f6cddf6c5f54d241edebac13ca51ffc Mon Sep 17 00:00:00 2001 From: Dominik 'Rathann' Mierzejewski Date: Fri, 9 Jun 2017 11:42:19 +0200 Subject: [PATCH 1/2] use correct int types This fixes ERRORs and FAILs in the testsuite on 32bit: TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe' and assert_(out[0].dtype == np.int64) File "/usr/lib/python2.7/site-packages/numpy/testing/utils.py", line 92, in assert_ raise AssertionError(smsg) AssertionError --- package/MDAnalysis/core/groups.py | 2 +- package/MDAnalysis/core/topology.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package/MDAnalysis/core/groups.py b/package/MDAnalysis/core/groups.py index c386e079ef0..f2459c9f1dd 100644 --- a/package/MDAnalysis/core/groups.py +++ b/package/MDAnalysis/core/groups.py @@ -419,7 +419,7 @@ def __init__(self, *args): ix, u = args # indices for the objects I hold - self._ix = np.asarray(ix, dtype=np.int64) + self._ix = np.asarray(ix, dtype=np.intp) self._u = u self._cache = dict() diff --git a/package/MDAnalysis/core/topology.py b/package/MDAnalysis/core/topology.py index 2c11d2f3632..2653acfb84d 100644 --- a/package/MDAnalysis/core/topology.py +++ b/package/MDAnalysis/core/topology.py @@ -125,12 +125,12 @@ def make_downshift_arrays(upshift, nparents): counter += 1 # If parent is skipped, eg (0, 0, 2, 2, etc) while counter != upshift[order[x:y][0]]: - downshift.append(np.array([], dtype=np.int)) + downshift.append(np.array([], dtype=np.int64)) counter += 1 - downshift.append(np.sort(np.array(order[x:y], copy=True, dtype=np.int))) + downshift.append(np.sort(np.array(order[x:y], copy=True, dtype=np.int64))) # Add entries for childless parents at end of range while counter < (nparents - 1): - downshift.append(np.array([], dtype=np.int)) + downshift.append(np.array([], dtype=np.int64)) counter += 1 # Add None to end of array to force it to be of type Object # Without this, a rectangular array gets squashed into a single array From 280dc138c7ec8d0f68015067307419474fab0643 Mon Sep 17 00:00:00 2001 From: Dominik 'Rathann' Mierzejewski Date: Fri, 9 Jun 2017 11:49:09 +0200 Subject: [PATCH 2/2] relax test_symmetry test due to lower precision on 32bit --- testsuite/MDAnalysisTests/analysis/test_psa.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/analysis/test_psa.py b/testsuite/MDAnalysisTests/analysis/test_psa.py index 3d4d097f10b..ddc0b8f4e71 100644 --- a/testsuite/MDAnalysisTests/analysis/test_psa.py +++ b/testsuite/MDAnalysisTests/analysis/test_psa.py @@ -221,7 +221,8 @@ def test_symmetry(self): for a given Hausdorff metric, h.''' forward = self.h(self.path_1, self.path_2) reverse = self.h(self.path_2, self.path_1) - self.assertEqual(forward, reverse) + # lower precision on 32bit + assert_almost_equal(forward, reverse, decimal=15) def test_hausdorff_value(self): '''Test that the undirected Hausdorff