Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 26, 2024
1 parent ed6aa65 commit be2bb38
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dpdata/abacus/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def process_file_input(file_input, atom_names, input_name):

if mag is None and data.get("spins") is not None and len(data["spins"]) > 0:
mag = data["spins"][frame_idx]

if move is None and data.get("move", None) is not None and len(data["move"]) > 0:
move = data["move"]

Expand Down
5 changes: 1 addition & 4 deletions dpdata/vasp/poscar.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ def from_system_data(system, f_idx=0, skip_zeros=True):
line = f"{ii_posi[0]:15.10f} {ii_posi[1]:15.10f} {ii_posi[2]:15.10f}"
if len(move) > 0:
move_flags = move[idx]
if (
isinstance(move_flags, list)
and len(move_flags) == 3
):
if isinstance(move_flags, list) and len(move_flags) == 3:
line += " " + " ".join(["T" if flag else "F" for flag in move_flags])
elif isinstance(move_flags, (int, float, bool)):
line += " " + " ".join(["T" if move_flags else "F"] * 3)

Check warning on line 119 in dpdata/vasp/poscar.py

View check run for this annotation

Codecov / codecov/patch

dpdata/vasp/poscar.py#L118-L119

Added lines #L118 - L119 were not covered by tests
Expand Down
4 changes: 2 additions & 2 deletions tests/test_vasp_poscar_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def test_dump_move_flags(self):
tmp_system.to_vasp_poscar("tmp.POSCAR")
self.system = dpdata.System()
self.system.from_vasp_poscar("tmp.POSCAR")
with open("tmp.POSCAR", "r") as f:
with open("tmp.POSCAR") as f:
content = f.read()

stru_ref = f"""Cartesian
stru_ref = """Cartesian
0.0000000000 0.0000000000 0.0000000000 T T F
1.2621856044 0.7018027835 0.5513883414 F F F
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vasp_poscar_to_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestPOSCARCart(unittest.TestCase, TestPOSCARoh):
def setUp(self):
self.system = dpdata.System()
self.system.from_vasp_poscar(os.path.join("poscars", "POSCAR.oh.c"))

def test_move_flags(self):
expected = np.array([[True, True, False], [False, False, False]])
self.assertTrue(np.array_equal(self.system["move"], expected))
Expand Down

0 comments on commit be2bb38

Please sign in to comment.