From b80990da114f6a8c20aec299349c53fb7b14ad87 Mon Sep 17 00:00:00 2001 From: Sean Kavanagh Date: Tue, 31 Oct 2023 19:38:46 +0000 Subject: [PATCH] Make tests compatible with python=3.8 and account for rare site-matching case with defective supercells used as input --- tests/test_generation.py | 10 +++++++++- tests/test_vasp.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_generation.py b/tests/test_generation.py index 595c3715..36c383b9 100644 --- a/tests/test_generation.py +++ b/tests/test_generation.py @@ -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( @@ -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 ( diff --git a/tests/test_vasp.py b/tests/test_vasp.py index 37d0752f..13be5dd5 100644 --- a/tests/test_vasp.py +++ b/tests/test_vasp.py @@ -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 ] )