<commit_before>#!/usr/bin/env python3
""" A set of classes used for computing the dynamic properties of a Hoomd MD
simulation"""

from __future__ import print_function
import collections
import numpy as np
from TransData import TransData, TransRotData


class CompDynamics(object):
    """ Class to compute the time dependent properties.

    This computes a number of dynamic quantities that are relevant to a
    molecular dynamics simulation.

    Args:
        TData (:class:`TransData.TransData`): A :class:`TransData.TransData`
            object containg the translational motion and time over which
            that translational motion took place.
    """

    def __init__(self, TData):
        assert issubclass(type(TData), TransData), type(TData)
        self.data = TData
        self._d_disp_compute = 0
        self._d_disp2_compute = 0
        self._d_disp4_compute = 0
        self._output_all = collections.OrderedDict()
        self._output_all['time'] = self.timestep
        self._output_all['disp'] = self.get_mean_disp
        self._output_all['msd'] = self.get_msd
        self._output_all['mfd'] = self.get_mfd
        self._output_all['alpha'] = self.get_alpha
        self._output_all['struct'] = self.get_struct

    def timestep(self):
        """Compute the timestep difference

        Return:
            int: The number of timesteps the displacement corresponds to
        """
        return self.data.timesteps

    def translations(self):
        """Return the translation of each molecule

        Return:
            :class:`numpy.ndarray`: An array of the translational motion that
            each molecule/particle underwent in a period of time.
        """
        return self.data.trans

    def _d_disp(self):
        """ Internal funtion to compute mean displacement
        """
        if self._d_disp_compute == 0:
            self._d_disp_compute = np.mean(self.translations())
        return self._d_disp_compute

    def _d_disp2(self):
        """Internal function to compute mean squared disp
        """
        if self._d_disp2_compute == 0:
            self._d_disp2_compute = np.mean(np.power(self.translations(), 2))
        return self._d_disp2_compute

    def _d_disp4(self):
        """Internal function to compute mean fourth disp
        """
        if self._d_disp4_compute == 0:
            self._d_disp_compute = np.mean(np.power(self.translations(), 4))
        return self._d_disp4_compute

    def get_mean_disp(self):
        R""" Compute the mean displacement

        Finds the mean displacement of the molecules using the
        :func:`numpy.mean` function.<commit_msg>Bugfix - Not computing MFD correctly<commit_after>#!/usr/bin/env python3
""" A set of classes used for computing the dynamic properties of a Hoomd MD
simulation"""

from __future__ import print_function
import collections
import numpy as np
from TransData import TransData, TransRotData


class CompDynamics(object):
    """ Class to compute the time dependent properties.

    This computes a number of dynamic quantities that are relevant to a
    molecular dynamics simulation.

    Args:
        TData (:class:`TransData.TransData`): A :class:`TransData.TransData`
            object containg the translational motion and time over which
            that translational motion took place.
    """

    def __init__(self, TData):
        assert issubclass(type(TData), TransData), type(TData)
        self.data = TData
        self._d_disp_compute = 0
        self._d_disp2_compute = 0
        self._d_disp4_compute = 0
        self._output_all = collections.OrderedDict()
        self._output_all['time'] = self.timestep
        self._output_all['disp'] = self.get_mean_disp
        self._output_all['msd'] = self.get_msd
        self._output_all['mfd'] = self.get_mfd
        self._output_all['alpha'] = self.get_alpha
        self._output_all['struct'] = self.get_struct

    def timestep(self):
        """Compute the timestep difference

        Return:
            int: The number of timesteps the displacement corresponds to
        """
        return self.data.timesteps

    def translations(self):
        """Return the translation of each molecule

        Return:
            :class:`numpy.ndarray`: An array of the translational motion that
            each molecule/particle underwent in a period of time.
        """
        return self.data.trans

    def _d_disp(self):
        """ Internal funtion to compute mean displacement
        """
        if self._d_disp_compute == 0:
            self._d_disp_compute = np.mean(self.translations())
        return self._d_disp_compute

    def _d_disp2(self):
        """Internal function to compute mean squared disp
        """
        if self._d_disp2_compute == 0:
            self._d_disp2_compute = np.mean(np.power(self.translations(), 2))
        return self._d_disp2_compute

    def _d_disp4(self):
        """Internal function to compute mean fourth disp
        """
        if self._d_disp4_compute == 0:
            self._d_disp4_compute = np.mean(np.power(self.translations(), 4))
        return self._d_disp4_compute

    def get_mean_disp(self):
        R""" Compute the mean displacement

        Finds the mean displacement of the molecules using the
        :func:`numpy.mean` function.
{'fraction_non_alphanumeric': 0.0856873822975518, 'fraction_numerical': 0.006967984934086629, 'mean_word_length': 2.5716207128446538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6046723', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1445, 'n_words': 435}