def project(self, *args, **kwargs): """ Project molecule. Parameters ---------- mol : :class:`Molecule <htmd.molecule.molecule.Molecule>` A :class:`Molecule <htmd.molecule.molecule.Molecule>` object to project. Returns ------- data : np.ndarray An array containing the projected data. """ # -------------- DEPRECATION PATCH -------------- if isinstance(self, np.ndarray) or isinstance(self, Molecule): from warnings import warn warn('Static use of the project method will be deprecated in the next version of HTMD. ' 'Please change your projection code according to the tutorials on www.htmd.org') data = _MetricDistanceOld.project(self, *args, **kwargs) logger.warning('Static use of the project method will be deprecated in the next version of HTMD. ' 'Please change your projection code according to the tutorials on www.htmd.org') return data # ------------------ CUT HERE ------------------- mol = args[0] (sel1, sel2) = self._getSelections(mol) if np.ndim(sel1) == 1 and np.ndim(sel2) == 1: # normal distances metric = pp_calcDistances(mol, sel1, sel2, self.metric, self.threshold, self.pbc, truncate=self.truncate) else: # minimum distances by groups metric = pp_calcMinDistances(mol, sel1, sel2) return metric
def project(self, mol): """ Project molecule. Parameters ---------- mol : :class:`Molecule <htmd.molecule.molecule.Molecule>` A :class:`Molecule <htmd.molecule.molecule.Molecule>` object to project. Returns ------- data : np.ndarray An array containing the projected data. """ (sel1, sel2) = self._getSelections(mol) if np.ndim(sel1) == 1 and np.ndim(sel2) == 1: # normal distances metric = pp_calcDistances(mol, sel1, sel2, self.metric, self.threshold, self.pbc, truncate=self.truncate) else: # minimum distances by groups metric = pp_calcMinDistances(mol, sel1, sel2, self.metric, self.threshold, pbc=self.pbc) return metric
def _processTraj(self, mol): (sel1, sel2) = self._getSelections(mol) if np.ndim(sel1) == 1 and np.ndim(sel2) == 1: # normal distances metric = pp_calcDistances(mol, sel1, sel2, self.metric, self.threshold, self.pbc, truncate=self.truncate) else: # minimum distances by groups metric = pp_calcMinDistances(mol, sel1, sel2) #if not issparse(metric) and not metric.dtype == 'bool' and np.any(np.isreal(metric)) and self.precision != 0: # metric = np.round(metric * (1 / self.precision)) * self.precision return metric