Skip to content

Fix UTs destroyed by pymatgen's update #1471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dpgen/data/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ def poscar_scale(poscar_in, poscar_out, scale):
except AttributeError:
poscar = Poscar.from_str("".join(lines))
with open(poscar_out, "w") as fout:
fout.write(poscar.get_string(direct=False))
try:
fout.write(poscar.get_string(direct=False))
except AttributeError:
fout.write(poscar.get_str(direct=False))


def make_scale(jdata):
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/bcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.0:.16f} {0.0:.16f} {0.0:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/diamond.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.12500000000000:.16f} {0.12500000000000:.16f} {0.12500000000000:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/fcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.0:.16f} {0.0:.16f} {0.0:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/hcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0:.16f} {0:.16f} {0:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/sc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.0:.16f} {0.0:.16f} {0.0:.16f}\n"
Expand Down
24 changes: 18 additions & 6 deletions tests/generator/test_make_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,10 @@ def _check_kpoints(testCase, idx):
ret = make_kspacing_kpoints(
os.path.join(os.path.join(ii, "POSCAR")), kspacing, gamma
)
kpoints_ref = Kpoints.from_string(ret)
try:
kpoints_ref = Kpoints.from_string(ret)
except AttributeError:
kpoints_ref = Kpoints.from_str(ret)
testCase.assertEqual(repr(kpoints), repr(kpoints_ref))


Expand Down Expand Up @@ -496,12 +499,21 @@ def _check_incar_ele_temp(testCase, idx, ele_temp):
tidx = int(bname.split(".")[2])
with open("INCAR") as fp:
incar = fp.read()
incar0 = Incar.from_string(incar)
try:
incar0 = Incar.from_string(incar)
except AttributeError:
incar0 = Incar.from_str(incar)
# make_fake_md: the frames in a system shares the same ele_temp
incar1 = Incar.from_string(
vasp_incar_ele_temp_ref
% (ele_temp[sidx][0] * pc.Boltzmann / pc.electron_volt)
)
try:
incar1 = Incar.from_string(
vasp_incar_ele_temp_ref
% (ele_temp[sidx][0] * pc.Boltzmann / pc.electron_volt)
)
except AttributeError:
incar1 = Incar.from_str(
vasp_incar_ele_temp_ref
% (ele_temp[sidx][0] * pc.Boltzmann / pc.electron_volt)
)
for ii in incar0.keys():
# skip checking nbands...
if ii == "NBANDS":
Expand Down