Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
htz1992213 committed Feb 5, 2024
1 parent d878a1c commit 867001b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 32 deletions.
8 changes: 2 additions & 6 deletions mdgo/coordination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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``.
Expand Down
4 changes: 1 addition & 3 deletions mdgo/msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 1 addition & 3 deletions mdgo/util/reformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
32 changes: 16 additions & 16 deletions tests/test_msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 867001b

Please sign in to comment.