fix bug in reading trajs with random tid#377
fix bug in reading trajs with random tid#377wanghan-iapcm merged 3 commits intodeepmodeling:develfrom
Conversation
wanghan-iapcm
left a comment
There was a problem hiding this comment.
I suggest an easier way of implementing the sorting according to type. Please check if I made anything wrong.
dpdata/lammps/dump.py
Outdated
| @@ -32,7 +43,8 @@ def get_atype(lines, type_idx_zero = False) : | |||
| atype = [] | |||
| for ii in blk : | |||
| atype.append([int(ii.split()[id_idx]), int(ii.split()[tidx])]) | |||
There was a problem hiding this comment.
| atype.append([int(ii.split()[id_idx]), int(ii.split()[tidx])]) | |
| atype.append([int(ii.split()[tid]), int(ii.split()[id_idx])]) |
dpdata/lammps/dump.py
Outdated
| posis.append([float(words[id_idx]), float(words[xidx]), float(words[yidx]), float(words[zidx])]) | ||
| posis.sort() | ||
| posis = np.array(posis)[:,1:4] | ||
| posis.append([float(words[id_idx]), float(words[tidx]), float(words[xidx]), float(words[yidx]), float(words[zidx])]) |
There was a problem hiding this comment.
| posis.append([float(words[id_idx]), float(words[tidx]), float(words[xidx]), float(words[yidx]), float(words[zidx])]) | |
| posis.append([float(words[tidx]), float(words[id_idx]), float(words[xidx]), float(words[yidx]), float(words[zidx])]) |
Then we do not need to implement _sort_tid_comparator
There was a problem hiding this comment.
Then we do not need to implement _sort_tid_comparator
@wanghan-iapcm
_sort_tid_comparator is used so that there is only one possibility for sorting.
In this case, we may get multiple orders when sorting. For example:
# order1
id type_id x y z
1 1 1.0 1.0 1.0
2 1 2.0 2.0 2.0
3 2 3.0 2.0 2.0
# order2
id type_id x y z
2 1 2.0 2.0 2.0
1 1 1.0 1.0 1.0
3 2 3.0 2.0 2.0
Would this be OK?
There was a problem hiding this comment.
please check
In [33]: a = [[1, 2, 1], [1, 1, 3]]
In [34]: a.sort()
In [35]: print(a)
[[1, 1, 3], [1, 2, 1]]
|
Complete! |
Codecov ReportBase: 82.28% // Head: 82.37% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## devel #377 +/- ##
==========================================
+ Coverage 82.28% 82.37% +0.09%
==========================================
Files 67 67
Lines 5898 5908 +10
==========================================
+ Hits 4853 4867 +14
+ Misses 1045 1041 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
fix #376