Skip to content

Commit

Permalink
add tests and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyminium committed Jan 17, 2021
1 parent ac94428 commit ad0a7f0
Show file tree
Hide file tree
Showing 22 changed files with 1,244 additions and 1,261 deletions.
3 changes: 2 additions & 1 deletion package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def _fit_to(mobile_coordinates, ref_coordinates, mobile_atoms,
"""
R, min_rmsd = rotation_matrix(mobile_coordinates, ref_coordinates,
weights=weights)

mobile_atoms.translate(-mobile_com)
mobile_atoms.rotate(R)
mobile_atoms.translate(ref_com)
Expand Down Expand Up @@ -630,7 +631,7 @@ def __init__(self, mobile, reference, select='all', filename=None,
select = rms.process_selection(select)
self.ref_atoms = reference.select_atoms(*select['reference']).atoms
self.mobile_atoms = mobile.select_atoms(*select['mobile']).atoms
if in_memory or not isinstance(mobile.trajectory, MemoryReader):
if in_memory or isinstance(mobile.trajectory, MemoryReader):
mobile.transfer_to_memory()
filename = None
logger.info("Moved mobile trajectory to in-memory representation")
Expand Down
10 changes: 6 additions & 4 deletions package/MDAnalysis/analysis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self, trajectory, verbose=False, **kwargs):
self._trajectory = trajectory
self._verbose = verbose

def _setup_frames(self, trajectory, start=None, stop=None, step=None):
def _setup_frames(self, trajectory, start=None, stop=None, step=None, frames=None):
"""
Pass a Reader object and define the desired iteration pattern
through the trajectory
Expand All @@ -139,7 +139,9 @@ def _setup_frames(self, trajectory, start=None, stop=None, step=None):
self.start = start
self.stop = stop
self.step = step
self.frame_indices = np.arange(start, stop, step)
if frames is None:
frames = np.arange(start, stop, step)
self.frame_indices = frames
self.n_frames = len(self.frame_indices)
self.frames = np.zeros(self.n_frames, dtype=int)
self.times = np.zeros(self.n_frames)
Expand All @@ -162,7 +164,7 @@ def _conclude(self):
"""
pass # pylint: disable=unnecessary-pass

def run(self, start=None, stop=None, step=None, verbose=None):
def run(self, start=None, stop=None, step=None, frames=None, verbose=None):
"""Perform the calculation
Parameters
Expand All @@ -181,7 +183,7 @@ def run(self, start=None, stop=None, step=None, verbose=None):
verbose = getattr(self, '_verbose',
False) if verbose is None else verbose

self._setup_frames(self._trajectory, start, stop, step)
self._setup_frames(self._trajectory, start, stop, step, frames)
logger.info("Starting preparation")
self._prepare()
for i, frame in enumerate(ProgressBar(self.frame_indices, verbose=verbose)):
Expand Down
23 changes: 23 additions & 0 deletions package/MDAnalysis/analysis/clustering/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- https://www.mdanalysis.org
# Copyright (c) 2006-2017 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.
# doi: 10.25080/majora-629e541a-00e
#
# 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
#

from .clusters import Clusters
from . import methods
7 changes: 0 additions & 7 deletions package/MDAnalysis/analysis/clustering/cluster_methods.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#
"""
Cython wrapper for the C implementation of the Affinity Perturbation clustering algorithm.
:Author: Matteo Tiberti, Wouter Boomsma, Tone Bengtsen
"""
import warnings

Expand Down Expand Up @@ -83,10 +80,6 @@ def affinity_propagation(similarity, preference, float lam, int max_iter, int co


cdef np.ndarray[np.float32_t, ndim=1] sim = np.ravel(similarity[indices]).astype(np.float32)
# sim = np.ascontiguousarray(sim)

print(sim)

cdef np.ndarray[long, ndim=1] clusters = np.zeros((cn), dtype=long)

# run C module Affinity Propagation
Expand Down
Empty file.
23 changes: 0 additions & 23 deletions package/MDAnalysis/analysis/clustering/include/ap.h

This file was deleted.

23 changes: 23 additions & 0 deletions package/MDAnalysis/analysis/clustering/methods.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- https://www.mdanalysis.org
# Copyright (c) 2006-2017 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.
# doi: 10.25080/majora-629e541a-00e
#
# 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
#

from . import cluster_methods

class AffinityPropagation:
Expand Down
191 changes: 0 additions & 191 deletions package/MDAnalysis/analysis/clustering/src/ap.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def __call__(self, distance_matrix):
max_iterations = self.max_iter,
convergence = self.convergence_iter,
noise=int(self.add_noise))
print(clusters)
raise ValueError()

return clusters

if sklearn:

class AffinityPropagation(ClusteringMethod):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ def AffinityPropagation(s, preference, float lam, int max_iterations, int conver

# Prepare input and ouput arrays
cdef numpy.ndarray[numpy.float32_t, ndim=1] matndarray = numpy.ascontiguousarray(s._elements, dtype=numpy.float32)

print(matndarray)
cdef numpy.ndarray[long, ndim=1] clusters = numpy.zeros((s.size),dtype=long)

# run C module Affinity Propagation
Expand Down
Loading

0 comments on commit ad0a7f0

Please sign in to comment.