From 4e117096d2f6c027bf73b61d9651d6f6cdf160da Mon Sep 17 00:00:00 2001 From: njzjz-bot Date: Mon, 24 Aug 2026 03:47:49 +0800 Subject: [PATCH 1/2] fix: apply remove_pbc to mixed configurations Apply the configured non-periodic transformation to every system reconstructed from a deepmd/npy/mixed dataset. Coding-Agent: Codex Codex-Version: codex-cli 0.149.1 Model: gpt-5.6-sol Reasoning-Effort: xhigh --- dpgen2/conf/file_conf.py | 6 ++++++ tests/conf/test_file_conf.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/dpgen2/conf/file_conf.py b/dpgen2/conf/file_conf.py index e8ae2443..cddca02d 100644 --- a/dpgen2/conf/file_conf.py +++ b/dpgen2/conf/file_conf.py @@ -79,6 +79,12 @@ def generate_mixed( assert "deepmd/npy/mixed" == self.fmt ms = dpdata.MultiSystems(type_map=type_map) ms.from_deepmd_npy_mixed(self.files[0], fmt="deepmd/npy/mixed", labeled=False) # type: ignore + if self.remove_pbc: + # Keep mixed-format configurations consistent with the standard + # file path: every reconstructed chemical system must receive the + # requested non-periodic cell transformation. + for system in ms.systems.values(): + system.remove_pbc() return ms @staticmethod diff --git a/tests/conf/test_file_conf.py b/tests/conf/test_file_conf.py index ec208522..2550e577 100644 --- a/tests/conf/test_file_conf.py +++ b/tests/conf/test_file_conf.py @@ -203,6 +203,22 @@ def test_deepmd_mixed(self): np.testing.assert_almost_equal(ms[1][tt], ms1[1][tt]) shutil.rmtree("test_mixed") + def test_deepmd_mixed_remove_pbc(self): + type_map = ["Cu", "Al", "Mg"] + ms = dpdata.MultiSystems(type_map=type_map) + ms.append(dpdata.System(Path(self.prefix) / "poscar.foo.0", fmt="vasp/poscar")) + ms.to("deepmd/npy/mixed", "test_mixed_remove_pbc") + self.addCleanup(shutil.rmtree, "test_mixed_remove_pbc", ignore_errors=True) + + loaded = FileConfGenerator( + "test_mixed_remove_pbc", + fmt="deepmd/npy/mixed", + remove_pbc=True, + ).generate(type_map) + + np.testing.assert_allclose(loaded[0]["cells"][0], np.eye(3) * 18.0) + np.testing.assert_allclose(loaded[0]["coords"][0, 0], np.full(3, 9.0)) + class TestFileConfGeneratorContent(unittest.TestCase): def test_list_1(self): From 88515a97a40ffb8acdd2abff48938753017c75e2 Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" Date: Wed, 7 Oct 2026 17:03:33 +0800 Subject: [PATCH 2/2] test: cover every mixed system when removing periodicity Verify both chemical systems and preserve type metadata; catches first-system-only mutation. Agent: dot --- tests/conf/test_file_conf.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/conf/test_file_conf.py b/tests/conf/test_file_conf.py index 2550e577..8f6c6785 100644 --- a/tests/conf/test_file_conf.py +++ b/tests/conf/test_file_conf.py @@ -206,7 +206,8 @@ def test_deepmd_mixed(self): def test_deepmd_mixed_remove_pbc(self): type_map = ["Cu", "Al", "Mg"] ms = dpdata.MultiSystems(type_map=type_map) - ms.append(dpdata.System(Path(self.prefix) / "poscar.foo.0", fmt="vasp/poscar")) + for filename in ["poscar.foo.0", "poscar.foo.1"]: + ms.append(dpdata.System(Path(self.prefix) / filename, fmt="vasp/poscar")) ms.to("deepmd/npy/mixed", "test_mixed_remove_pbc") self.addCleanup(shutil.rmtree, "test_mixed_remove_pbc", ignore_errors=True) @@ -216,8 +217,13 @@ def test_deepmd_mixed_remove_pbc(self): remove_pbc=True, ).generate(type_map) - np.testing.assert_allclose(loaded[0]["cells"][0], np.eye(3) * 18.0) - np.testing.assert_allclose(loaded[0]["coords"][0, 0], np.full(3, 9.0)) + self.assertEqual(len(loaded), 2) + for original, system in zip(ms, loaded): + with self.subTest(formula=system.formula): + np.testing.assert_allclose(system["cells"][0], np.eye(3) * 18.0) + np.testing.assert_allclose(system["coords"][0, 0], np.full(3, 9.0)) + for field in ["atom_names", "atom_numbs", "atom_types"]: + np.testing.assert_equal(system[field], original[field]) class TestFileConfGeneratorContent(unittest.TestCase):