From 867001b123a4d24e30e0ef4510a52a36a9a41d20 Mon Sep 17 00:00:00 2001 From: Tingzheng Hou <25351437+htz1992213@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:56:25 +0800 Subject: [PATCH] lint --- mdgo/coordination.py | 8 ++------ mdgo/msd.py | 4 +--- mdgo/util/reformat.py | 4 +--- setup.py | 2 +- tests/test_msd.py | 32 ++++++++++++++++---------------- tests/test_volume.py | 4 +--- 6 files changed, 22 insertions(+), 32 deletions(-) diff --git a/mdgo/coordination.py b/mdgo/coordination.py index c142ae2e..f7c350eb 100644 --- a/mdgo/coordination.py +++ b/mdgo/coordination.py @@ -363,9 +363,7 @@ def check_contiguous_steps( An array of distance between the center atom and the neighbor atoms in the checkpoint +/- lag time range. """ - coord_num: dict[str, list[list[int]] | np.ndarray] = { - x: [[] for _ in range(lag * 2 + 1)] for x in distance_dict - } + coord_num: dict[str, list[list[int]] | np.ndarray] = {x: [[] for _ in range(lag * 2 + 1)] for x in distance_dict} trj_analysis = nvt_run.trajectory[run_start:run_end:] has = False for i, _ts in enumerate(trj_analysis): @@ -1092,9 +1090,7 @@ def write_out(center_pos: np.ndarray, center_name: str, neighbors: AtomGroup, pa xyz_file.write("\n".join(lines)) -def select_shell( - select: dict[str, str] | str, distance: dict[str, float] | str, center_atom: Atom, kw: str -) -> str: +def select_shell(select: dict[str, str] | str, distance: dict[str, float] | str, center_atom: Atom, kw: str) -> str: """ Select a group of atoms that is within a distance of an ``center_atom``. diff --git a/mdgo/msd.py b/mdgo/msd.py index b3a50412..f8c6d6c9 100644 --- a/mdgo/msd.py +++ b/mdgo/msd.py @@ -284,9 +284,7 @@ def parse_msd_type(msd_type: DIM) -> list[int]: try: dim = keys[msd_type_str] except KeyError: - raise ValueError( - f"invalid msd_type: {msd_type_str} specified, please specify one of xyz, xy, xz, yz, x, y, z" - ) + raise ValueError(f"invalid msd_type: {msd_type_str} specified, please specify one of xyz, xy, xz, yz, x, y, z") return dim diff --git a/mdgo/util/reformat.py b/mdgo/util/reformat.py index 616390d0..ec5d4a68 100644 --- a/mdgo/util/reformat.py +++ b/mdgo/util/reformat.py @@ -68,9 +68,7 @@ }, } -BOX: Final[ - str -] = """{0:6f} {1:6f} xlo xhi +BOX: Final[str] = """{0:6f} {1:6f} xlo xhi {0:6f} {1:6f} ylo yhi {0:6f} {1:6f} zlo zhi""" diff --git a/setup.py b/setup.py index d08a09bc..fa75a4ea 100644 --- a/setup.py +++ b/setup.py @@ -71,7 +71,7 @@ "Topic :: Scientific/Engineering :: Physics", "Topic :: Scientific/Engineering :: Chemistry", "Topic :: Software Development :: Libraries :: Python Modules", - ], + ], packages=find_packages(), install_requires=INSTALL_REQUIRES, extras_require={ diff --git a/tests/test_msd.py b/tests/test_msd.py index aa226b6d..bc7dab97 100644 --- a/tests/test_msd.py +++ b/tests/test_msd.py @@ -55,36 +55,36 @@ def test_msd_fft(self): def test_create_position_arrays(self): assert_allclose( np.array([21.53381769, 14.97501839, -3.87998785]), - create_position_arrays(self.gen2, 0, 100, select="type 3")[50][2] + create_position_arrays(self.gen2, 0, 100, select="type 3")[50][2], ) assert_allclose( np.array([-2.78550047, -11.85487624, -17.1221954]), - create_position_arrays(self.gen2, 0, 100, select="type 3")[99][10] + create_position_arrays(self.gen2, 0, 100, select="type 3")[99][10], ) assert_allclose( - np.array([41.1079216 , 34.95127106, 18.00482368]), - create_position_arrays(self.gen2, 0, 100, select="type 3", center_of_mass=False)[50][2] + np.array([41.1079216, 34.95127106, 18.00482368]), + create_position_arrays(self.gen2, 0, 100, select="type 3", center_of_mass=False)[50][2], ) assert_allclose( - np.array([16.98478317, 8.27190208, 5.07116079]), - create_position_arrays(self.gen2, 0, 100, select="type 3", center_of_mass=False)[99][10] + np.array([16.98478317, 8.27190208, 5.07116079]), + create_position_arrays(self.gen2, 0, 100, select="type 3", center_of_mass=False)[99][10], ) def test_parse_msd_type(self): xyz = parse_msd_type("xyz") - assert ["x", "y", "z"] == self.dims[xyz[0]:xyz[1]:xyz[2]] + assert ["x", "y", "z"] == self.dims[xyz[0] : xyz[1] : xyz[2]] xy = parse_msd_type("xy") - assert ["x", "y"] == self.dims[xy[0]:xy[1]:xy[2]] + assert ["x", "y"] == self.dims[xy[0] : xy[1] : xy[2]] yz = parse_msd_type("yz") - assert ["y", "z"] == self.dims[yz[0]:yz[1]:yz[2]] + assert ["y", "z"] == self.dims[yz[0] : yz[1] : yz[2]] xz = parse_msd_type("xz") - assert ["x", "z"] == self.dims[xz[0]:xz[1]:xz[2]] + assert ["x", "z"] == self.dims[xz[0] : xz[1] : xz[2]] x = parse_msd_type("x") - assert ["x"] == self.dims[x[0]:x[1]:x[2]] + assert ["x"] == self.dims[x[0] : x[1] : x[2]] y = parse_msd_type("y") - assert ["y"] == self.dims[y[0]:y[1]:y[2]] + assert ["y"] == self.dims[y[0] : y[1] : y[2]] z = parse_msd_type("z") - assert ["z"] == self.dims[z[0]:z[1]:z[2]] + assert ["z"] == self.dims[z[0] : z[1] : z[2]] def test_onsager_ii_self(self): onsager_ii_self_fft = onsager_ii_self(self.gen2, 0, 100, select="type 3") @@ -155,9 +155,9 @@ def test_total_msd(self): assert_allclose(total_builtin_cation[50], 32.14254152556588) assert_allclose(total_mda_cation[50], 32.338364098424634) with pytest.raises( - ValueError, - match="Warning! MDAnalysis does not support subtracting center " - "of mass. Calculating without subtracting...", + ValueError, + match="Warning! MDAnalysis does not support subtracting center " + "of mass. Calculating without subtracting...", ): total_msd(self.gen2, 0, 100, select="type 3", fft=True, built_in=False, center_of_mass=True) diff --git a/tests/test_volume.py b/tests/test_volume.py index 86b10c54..2f2efcba 100644 --- a/tests/test_volume.py +++ b/tests/test_volume.py @@ -50,9 +50,7 @@ def test_molecular_volume(self) -> None: litfsi_volume_4 = molecular_volume(self.litfsi, radii_type="Lange") litfsi_volume_5 = molecular_volume(self.litfsi, radii_type="pymatgen") litfsi_volume_6 = molecular_volume(self.litfsi, molar_volume=False) - litfsi_volume_7 = molecular_volume( - self.litfsi, mode="act", x_size=8, y_size=8, z_size=8 - ) + litfsi_volume_7 = molecular_volume(self.litfsi, mode="act", x_size=8, y_size=8, z_size=8) assert litfsi_volume_1 == 100.16 assert litfsi_volume_2 == 100.16 assert litfsi_volume_3 == 99.37