Skip to content

Commit

Permalink
Make tests compatible with python=3.8 and account for rare site-match…
Browse files Browse the repository at this point in the history
…ing case with defective supercells used as input
  • Loading branch information
kavanase committed Oct 31, 2023
1 parent 44a7143 commit b80990d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion tests/test_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,12 @@ def _random_equiv_supercell_sites_check(self, defect_entry):
distance_matrix = defect_entry.defect_supercell.distance_matrix
min_dist = min(distance_matrix[distance_matrix > 0.01])
print(min_dist)

min_dist_in_bulk = min( # account for rare case where defect introduction _increases_ the
# minimum atomic distance (e.g. vacancy in defect supercell that had an interstitial)
defect_entry.bulk_supercell.distance_matrix[defect_entry.bulk_supercell.distance_matrix > 0.01]
)

for equiv_defect_supercell_site in defect_entry.equivalent_supercell_sites:
new_defect_structure = defect_entry.bulk_supercell.copy()
new_defect_structure.append(
Expand All @@ -933,7 +939,9 @@ def _random_equiv_supercell_sites_check(self, defect_entry):
distance_matrix = new_defect_structure.distance_matrix
equiv_min_dist = min(distance_matrix[distance_matrix > 0.01])
print(equiv_min_dist)
assert np.isclose(min_dist, equiv_min_dist, atol=0.01)
assert np.isclose(min_dist, equiv_min_dist, atol=0.01) or np.isclose(
min_dist_in_bulk, equiv_min_dist, atol=0.01
)

def _check_editing_defect_gen(self, random_defect_entry_name, defect_gen):
assert (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _check_no_potcar_available_warning_error(symbol, message):
x in str(message)
for x in [
f"No POTCAR for {symbol} with functional",
"Please set the PMG_VASP_PSP_DIR in .pmgrc.yaml.",
"Please set the PMG_VASP_PSP_DIR", # message differs slightly for python 3.8 vs >=3.9
]
)

Expand Down

0 comments on commit b80990d

Please sign in to comment.