Skip to content

Commit 94ac622

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 582e04e commit 94ac622

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

dpdata/formats/abacus/stru.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,24 @@ def get_frame_from_stru(stru):
498498
for i in atom_names:
499499
if i not in uniq_name:
500500
uniq_name.append(i)
501-
uniq_atom_num.append(sum([atom_numbs[j] for j in range(len(atom_names)) if atom_names[j] == i]))
501+
uniq_atom_num.append(
502+
sum(
503+
[
504+
atom_numbs[j]
505+
for j in range(len(atom_names))
506+
if atom_names[j] == i
507+
]
508+
)
509+
)
502510
data = {
503511
"atom_names": uniq_name,
504512
"atom_numbs": uniq_atom_num,
505513
"atom_types": np.array(
506-
[uniq_name.index(atom_names[i]) for i in range(len(atom_numbs)) for j in range(atom_numbs[i])]
514+
[
515+
uniq_name.index(atom_names[i])
516+
for i in range(len(atom_numbs))
517+
for j in range(atom_numbs[i])
518+
]
507519
),
508520
"masses": np.array([masses[atom_names.index(i)] for i in uniq_name]),
509521
"pp_files": [pp_files[atom_names.index(i)] for i in uniq_name],

tests/test_abacus_stru_dump.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ def test_dump_stru_with_repeat_atomtype(self):
281281
with open("STRU_tmp") as f:
282282
c = f.read()
283283
self.assertTrue(
284-
"ATOMIC_SPECIES\nC 12.000 C_ONCV_PBE-1.0.upf\nH 1.000 H_ONCV_PBE-1.0.upf" in c
284+
"ATOMIC_SPECIES\nC 12.000 C_ONCV_PBE-1.0.upf\nH 1.000 H_ONCV_PBE-1.0.upf"
285+
in c
285286
)
286287
self.assertTrue("H\n0.0\n4\n" in c)
287288
os.remove("STRU_tmp")

0 commit comments

Comments
 (0)