From 0e0fc1a63e478d3e56285b520b34a9c58488d659 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Fri, 26 Jul 2024 22:28:05 -0400 Subject: [PATCH] fix: fix nopbc in dpdata driver (#4027) Sometimes dpdata data may contain `"nopbc": False` (from ase or n2p2). ## Summary by CodeRabbit - **Bug Fixes** - Improved handling of the "nopbc" key in the data processing logic, enhancing the accuracy of cell variable assignments. Signed-off-by: Jinzhe Zeng --- deepmd/driver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deepmd/driver.py b/deepmd/driver.py index 0b48f2ac84..998edcbc18 100644 --- a/deepmd/driver.py +++ b/deepmd/driver.py @@ -62,7 +62,8 @@ def label(self, data: dict) -> dict: atype = sorted_data["atom_types"] coord = data["coords"].reshape((nframes, natoms * 3)) - if "nopbc" not in data: + # sometimes data["nopbc"] may be False + if not data.get("nopbc", False): cell = data["cells"].reshape((nframes, 9)) else: cell = None