From d4775075b884e628243e695e141681566e10ffef Mon Sep 17 00:00:00 2001 From: marian-code Date: Thu, 14 Oct 2021 01:57:52 +0200 Subject: [PATCH] Fix the bug when type_map has only one element (#1196) * Update data.py Numpy has a bit odd behavior I ran into. The method `ndarray.loadtxt()` when loading from array file of length 1 outputs only the array element, not array of length=1. ```python import numpy as np np.__version__ "1.20.3" !cat array.raw A np.loadtxt("array.raw").tolist() "A" ``` * satisfy suggestions --- deepmd/utils/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepmd/utils/data.py b/deepmd/utils/data.py index ecf4aaeaba..99337aa41d 100644 --- a/deepmd/utils/data.py +++ b/deepmd/utils/data.py @@ -508,7 +508,7 @@ def _make_idx_map(self, atom_type): def _load_type_map(self, sys_path: DPPath) : fname = sys_path / 'type_map.raw' if fname.is_file() : - return fname.load_txt(dtype=str).tolist() + return fname.load_txt(dtype=str, ndmin=1).tolist() else : return None