Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Chronological list of authors
- Sang Young Noh
- Andrew William King
- Kathleen Clark
- Dominik 'Rathann' Mierzejewski


External code
-------------
Expand Down
3 changes: 2 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ The rules for this file:
------------------------------------------------------------------------------
mm/dd/17

* 0.16.2 richardjgowers
* 0.16.2 richardjgowers, rathann

Enhancements

Fixes
* fixed GROWriter truncating long resids from the wrong end (Issue #1395)
* Fixed dtype of numpy arrays to accomodate 32 bit architectures (Issue #1362)

Changes

Expand Down
6 changes: 3 additions & 3 deletions package/MDAnalysis/core/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -2464,7 +2464,7 @@ def ix_array(self):
--------
ix
"""
return np.array([self.ix])
return np.array([self.ix], dtype=np.intp)


class Atom(ComponentBase):
Expand Down Expand Up @@ -2736,7 +2736,7 @@ def update_selection(self):
ix = sum([sel.apply(bg) for sel in sels[1:]],
sels[0].apply(bg)).ix
else:
ix = np.array([], dtype=np.int)
ix = np.array([], dtype=np.intp)
# Run back through AtomGroup init with this information to remake ourselves
super(UpdatingAtomGroup, self).__init__(ix, self.universe)
self.is_uptodate = True
Expand Down
14 changes: 7 additions & 7 deletions package/MDAnalysis/core/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.intp))
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.intp)))
# 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.intp))
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
Expand Down Expand Up @@ -210,18 +210,18 @@ def __init__(self,

# built atom-to-residue mapping, and vice-versa
if atom_resindex is None:
self._AR = np.zeros(n_atoms, dtype=np.int64)
self._AR = np.zeros(n_atoms, dtype=np.intp)
else:
self._AR = atom_resindex.copy()
self._AR = np.asarray(atom_resindex, dtype=np.intp).copy()
if not len(self._AR) == n_atoms:
raise ValueError("atom_resindex must be len n_atoms")
self._RA = make_downshift_arrays(self._AR, n_residues)

# built residue-to-segment mapping, and vice-versa
if residue_segindex is None:
self._RS = np.zeros(n_residues, dtype=np.int64)
self._RS = np.zeros(n_residues, dtype=np.intp)
else:
self._RS = residue_segindex.copy()
self._RS = np.asarray(residue_segindex, dtype=np.intp).copy()
if not len(self._RS) == n_residues:
raise ValueError("residue_segindex must be len n_residues")
self._SR = make_downshift_arrays(self._RS, n_segments)
Expand Down
3 changes: 2 additions & 1 deletion testsuite/MDAnalysisTests/analysis/test_psa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
92 changes: 92 additions & 0 deletions testsuite/MDAnalysisTests/core/test_index_dtype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8
#
# MDAnalysis --- http://www.mdanalysis.org
# Copyright (c) 2006-2016 The MDAnalysis Development Team and contributors
# (see the file AUTHORS for the full list of names)
#
# Released under the GNU Public Licence, v2 or any higher version
#
# Please cite your use of MDAnalysis in published work:
#
# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler,
# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein.
# MDAnalysis: A Python package for the rapid analysis of molecular dynamics
# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th
# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy.
#
# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#

"""32 bit compat tests

Tests for making sure that integer arrays used for indexing use `np.intp`.
This dtype is important for platform independent indexing of other arrays.

"""
from __future__ import absolute_import

import numpy as np
from numpy.testing import (
assert_,
)
from MDAnalysisTests import make_Universe


class TestIndexDtype(object):
def setUp(self):
self.u = make_Universe()

def tearDown(self):
del self.u

def test_ag_ix(self):
assert_(self.u.atoms.ix.dtype == np.intp)

def test_rg_ix(self):
assert_(self.u.residues.ix.dtype == np.intp)

def test_sg_ix(self):
assert_(self.u.segments.ix.dtype == np.intp)

def test_atom_ix_array(self):
assert_(self.u.atoms[0].ix_array.dtype == np.intp)

def test_residue_ix_array(self):
assert_(self.u.residues[0].ix_array.dtype == np.intp)

def test_segment_ix_array(self):
assert_(self.u.segments[0].ix_array.dtype == np.intp)

def test_atomgroup_indices(self):
assert_(self.u.atoms.indices.dtype == np.intp)

def test_atomgroup_residue_upshift(self):
assert_(self.u.atoms.resindices.dtype == np.intp)

def test_atomgroup_segment_upshift(self):
assert_(self.u.atoms.segindices.dtype == np.intp)

def test_residuegroup_atom_downshift(self):
# downshift arrays are a list (one for each residue)
assert_(all((arr.dtype == np.intp)
for arr in self.u.residues.indices))

def test_residuegroup_resindices(self):
assert_(self.u.residues.resindices.dtype == np.intp)

def test_residuegroup_segment_upshift(self):
assert_(self.u.residues.segindices.dtype == np.intp)

def test_segmentgroup_atom_downshift(self):
assert_(all((arr.dtype == np.intp)
for arr in self.u.segments.indices))

def test_segmentgroup_residue_downshift(self):
assert_(all((arr.dtype == np.intp)
for arr in self.u.segments.resindices))

def test_segmentgroup_segindices(self):
assert_(self.u.segments.segindices.dtype == np.intp)