Skip to content

Commit d477507

Browse files
authored
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
1 parent 5a84796 commit d477507

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

deepmd/utils/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def _make_idx_map(self, atom_type):
508508
def _load_type_map(self, sys_path: DPPath) :
509509
fname = sys_path / 'type_map.raw'
510510
if fname.is_file() :
511-
return fname.load_txt(dtype=str).tolist()
511+
return fname.load_txt(dtype=str, ndmin=1).tolist()
512512
else :
513513
return None
514514

0 commit comments

Comments
 (0)