From 9b45a1a7bd5df0514543dbbec412f6666cae4270 Mon Sep 17 00:00:00 2001 From: Sebastian Kloth Date: Tue, 5 Dec 2023 16:44:26 +0100 Subject: [PATCH] Applied black formatter --- src/mdevaluate/chill.py | 6 +++--- src/mdevaluate/coordinates.py | 2 +- src/mdevaluate/distribution.py | 10 ++++++---- src/mdevaluate/system.py | 1 + src/mdevaluate/utils.py | 34 +++++++++++++++++----------------- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/mdevaluate/chill.py b/src/mdevaluate/chill.py index 5b49d66..dfb0bc5 100644 --- a/src/mdevaluate/chill.py +++ b/src/mdevaluate/chill.py @@ -23,9 +23,9 @@ def a_ij(atoms, N=4, l=3): qilm = np.average(qijlm, axis=1) qil = np.sum(qilm * np.conj(qilm), axis=-1) ** 0.5 aij = ( - np.sum(qilm[:, np.newaxis, :] * np.conj(qilm[indices]), axis=-1) - / qil[:, np.newaxis] - / qil[indices] + np.sum(qilm[:, np.newaxis, :] * np.conj(qilm[indices]), axis=-1) + / qil[:, np.newaxis] + / qil[indices] ) return np.real(aij), indices diff --git a/src/mdevaluate/coordinates.py b/src/mdevaluate/coordinates.py index 9bf5f88..c8888a0 100755 --- a/src/mdevaluate/coordinates.py +++ b/src/mdevaluate/coordinates.py @@ -590,4 +590,4 @@ def cylindrical_coordinates(frame, origin=None): z = frame[:, 2] radius = (x**2 + y**2) ** 0.5 phi = np.arctan2(y, x) - return np.array([radius, phi, z]).T \ No newline at end of file + return np.array([radius, phi, z]).T diff --git a/src/mdevaluate/distribution.py b/src/mdevaluate/distribution.py index d3c113e..e57eb37 100644 --- a/src/mdevaluate/distribution.py +++ b/src/mdevaluate/distribution.py @@ -114,11 +114,12 @@ def calc_gr( as large as possible, depending on the available memory. returnx (opt.): If True the x ordinate of the histogram is returned. """ + def gr_frame( - atoms_a: CoordinateFrame, - atoms_b: CoordinateFrame, - bins: ArrayLike, - remove_intra: bool = False, + atoms_a: CoordinateFrame, + atoms_b: CoordinateFrame, + bins: ArrayLike, + remove_intra: bool = False, ): box = atoms_b.box n = len(atoms_a) / np.prod(np.diag(box)) @@ -434,6 +435,7 @@ def hbonds( else: return pairs[is_bond] + def calc_cluster_sizes(frame, r_max=0.35): frame_PBC, indices_PBC = pbc_points( frame, frame.box, thickness=r_max + 0.1, index=True diff --git a/src/mdevaluate/system.py b/src/mdevaluate/system.py index 17936ad..24bb810 100644 --- a/src/mdevaluate/system.py +++ b/src/mdevaluate/system.py @@ -6,6 +6,7 @@ from typing import Iterable import pandas as pd from tables import NoSuchNodeError + @dataclass(kw_only=True) class MDSystem(abc.ABC): load_only_results: bool = False diff --git a/src/mdevaluate/utils.py b/src/mdevaluate/utils.py index e2d3d29..916b659 100644 --- a/src/mdevaluate/utils.py +++ b/src/mdevaluate/utils.py @@ -35,17 +35,17 @@ def five_point_stencil(xdata, ydata): See: https://en.wikipedia.org/wiki/Five-point_stencil """ return xdata[2:-2], ( - (-ydata[4:] + 8 * ydata[3:-1] - 8 * ydata[1:-3] + ydata[:-4]) - / (3 * (xdata[4:] - xdata[:-4])) + (-ydata[4:] + 8 * ydata[3:-1] - 8 * ydata[1:-3] + ydata[:-4]) + / (3 * (xdata[4:] - xdata[:-4])) ) def filon_fourier_transformation( - time, - correlation, - frequencies=None, - derivative="linear", - imag=True, + time, + correlation, + frequencies=None, + derivative="linear", + imag=True, ): """ Fourier-transformation for slow varrying functions. The filon algorithmus is @@ -89,25 +89,25 @@ def filon_fourier_transformation( else: raise NotImplementedError( 'Invalid approximation method {}. Possible values are "linear", "stencil" ' - 'or a list of values.' + "or a list of values." ) time = time.reshape(-1, 1) integral = ( - np.cos(frequencies * time[1:]) - np.cos(frequencies * time[:-1]) - ) / frequencies ** 2 + np.cos(frequencies * time[1:]) - np.cos(frequencies * time[:-1]) + ) / frequencies**2 fourier = (derivative * integral).sum(axis=0) if imag: integral = ( - 1j - * (np.sin(frequencies * time[1:]) - np.sin(frequencies * time[:-1])) - / frequencies ** 2 + 1j + * (np.sin(frequencies * time[1:]) - np.sin(frequencies * time[:-1])) + / frequencies**2 ) fourier = ( - fourier - + (derivative * integral).sum(axis=0) - + 1j * correlation[0] / frequencies + fourier + + (derivative * integral).sum(axis=0) + + 1j * correlation[0] / frequencies ) return ( @@ -498,5 +498,5 @@ def timing(function): time_needed = end_time - start_time print(f"Finished in {int(time_needed // 60)} min " f"{int(time_needed % 60)} s") return result - return wrap + return wrap