diff --git a/dpdata/abacus/scf.py b/dpdata/abacus/scf.py index 1102f299d..87b95c287 100644 --- a/dpdata/abacus/scf.py +++ b/dpdata/abacus/scf.py @@ -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"] diff --git a/dpdata/vasp/poscar.py b/dpdata/vasp/poscar.py index 7ece25357..5b73b71b1 100644 --- a/dpdata/vasp/poscar.py +++ b/dpdata/vasp/poscar.py @@ -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) diff --git a/tests/test_vasp_poscar_dump.py b/tests/test_vasp_poscar_dump.py index c04023fd1..d55228117 100644 --- a/tests/test_vasp_poscar_dump.py +++ b/tests/test_vasp_poscar_dump.py @@ -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 """ diff --git a/tests/test_vasp_poscar_to_system.py b/tests/test_vasp_poscar_to_system.py index 3e43afdf0..745c0bb7f 100644 --- a/tests/test_vasp_poscar_to_system.py +++ b/tests/test_vasp_poscar_to_system.py @@ -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))