Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 9, 2024
1 parent 837a4b1 commit aba74b2
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions dpdata/abacus/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ def make_unlabeled_stru(
If True, then only filename will be written in the STRU file, and make a soft link to the real file.
dest_dir : str, optional
The destination directory to make the soft link of the pseudo potential files and orbital files.
For velocity, mag, angle1, angle2, sc, and lambda_, if the value is None, then the corresponding information will not be written.
ABACUS support defining "mag" and "angle1"/"angle2" at the same time, and in this case, the "mag" only define the norm of the magnetic moment, and "angle1" and "angle2" define the direction of the magnetic moment.
If data has spins, then it will be written as mag to STRU file; while if mag is passed at the same time, then mag will be used.
Expand Down Expand Up @@ -686,19 +685,25 @@ def ndarray2list(i):
if pp_file is not None:
pp_file = ndarray2list(pp_file)
ppfiles = None
if isinstance(pp_file,(list, tuple)):
assert len(pp_file) == len(data["atom_names"]), "ERROR: make_unlabeled_stru: pp_file length is not equal to the number of atom types"
if isinstance(pp_file, (list, tuple)):
assert (
len(pp_file) == len(data["atom_names"])
), "ERROR: make_unlabeled_stru: pp_file length is not equal to the number of atom types"
ppfiles = pp_file
elif isinstance(pp_file, dict):
for iele in data["atom_names"]:
if iele not in pp_file:
raise RuntimeError(f"ERROR: make_unlabeled_stru: pp_file does not contain {iele}")
ppfiles = [pp_file[data["atom_names"][i]] for i in range(len(data["atom_names"]))]
raise RuntimeError(

Check warning on line 696 in dpdata/abacus/scf.py

View check run for this annotation

Codecov / codecov/patch

dpdata/abacus/scf.py#L696

Added line #L696 was not covered by tests
f"ERROR: make_unlabeled_stru: pp_file does not contain {iele}"
)
ppfiles = [
pp_file[data["atom_names"][i]] for i in range(len(data["atom_names"]))
]
else:
raise RuntimeError(f"ERROR: invalid pp_file: {pp_file}")

Check warning on line 703 in dpdata/abacus/scf.py

View check run for this annotation

Codecov / codecov/patch

dpdata/abacus/scf.py#L703

Added line #L703 was not covered by tests
else:
ppfiles = None

Check warning on line 705 in dpdata/abacus/scf.py

View check run for this annotation

Codecov / codecov/patch

dpdata/abacus/scf.py#L705

Added line #L705 was not covered by tests

for iele in range(len(data["atom_names"])):
if data["atom_numbs"][iele] == 0:
continue
Expand All @@ -724,17 +729,28 @@ def ndarray2list(i):
numerical_orbital = ndarray2list(numerical_orbital)
orbfiles = []
if isinstance(numerical_orbital, (list, tuple)):
assert len(numerical_orbital) == len(data["atom_names"]), "ERROR: make_unlabeled_stru: numerical_orbital length is not equal to the number of atom types"
orbfiles = [numerical_orbital[i] for i in range(len(data["atom_names"])) if data["atom_numbs"][i] != 0]
assert (
len(numerical_orbital) == len(data["atom_names"])
), "ERROR: make_unlabeled_stru: numerical_orbital length is not equal to the number of atom types"
orbfiles = [
numerical_orbital[i]
for i in range(len(data["atom_names"]))
if data["atom_numbs"][i] != 0
]
elif isinstance(numerical_orbital, dict):
for iele in data["atom_names"]:
if iele not in numerical_orbital:
raise RuntimeError(f"ERROR: make_unlabeled_stru: numerical_orbital does not contain {iele}")
orbfiles = [numerical_orbital[data["atom_names"][i]] for i in range(len(data["atom_names"])) if data["atom_numbs"][i] != 0]
raise RuntimeError(

Check warning on line 743 in dpdata/abacus/scf.py

View check run for this annotation

Codecov / codecov/patch

dpdata/abacus/scf.py#L743

Added line #L743 was not covered by tests
f"ERROR: make_unlabeled_stru: numerical_orbital does not contain {iele}"
)
orbfiles = [
numerical_orbital[data["atom_names"][i]]
for i in range(len(data["atom_names"]))
if data["atom_numbs"][i] != 0
]
else:
raise RuntimeError(f"ERROR: invalid numerical_orbital: {numerical_orbital}")

Check warning on line 752 in dpdata/abacus/scf.py

View check run for this annotation

Codecov / codecov/patch

dpdata/abacus/scf.py#L752

Added line #L752 was not covered by tests



out += "NUMERICAL_ORBITAL\n"
for iorb in orbfiles:
if not link_file:
Expand Down

0 comments on commit aba74b2

Please sign in to comment.