Skip to content

Commit

Permalink
increase coverage, added % symbol to calc qualtiy text
Browse files Browse the repository at this point in the history
  • Loading branch information
naik-aakash committed Aug 16, 2023
1 parent 6a8b5e1 commit f1cf2a6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lobsterpy/cohp/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def get_calc_quality_description(quality_dict):

elif key == "charge_spilling":
text_des.append(
"The absolute and total charge spilling for the calculation are {} and {}, "
"The absolute and total charge spilling for the calculation are {} and {} %, "
"respectively.".format(
quality_dict[key]["abs_charge_spilling"],
quality_dict[key]["abs_total_spilling"],
Expand Down
4 changes: 2 additions & 2 deletions lobsterpy/cohp/test/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def test_calc_quality_description_text(self):
calc_quality_k3sb_des,
[
"The LOBSTER calculation used minimal basis.",
"The absolute and total charge spilling for the calculation are 0.83 and 6.36, respectively.",
"The absolute and total charge spilling for the calculation are 0.83 and 6.36 %, respectively.",
"The bandOverlaps.lobster file is generated during LOBSTER run. This indicates that the projected wave function is not completely orthonormalized, however the maximal deviation values observed compared to the identity matrix is below the threshold 0.1.",
"The atomic charge signs from Mulliken population analysis agree with the bond valence analysis.",
"The atomic charge signs from Loewdin population analysis agree with the bond valence analysis.",
Expand All @@ -494,7 +494,7 @@ def test_calc_quality_description_text(self):
calc_quality_csh_des,
[
"The LOBSTER calculation used minimal basis.",
"The absolute and total charge spilling for the calculation are 3.01 and 13.73, respectively.",
"The absolute and total charge spilling for the calculation are 3.01 and 13.73 %, respectively.",
"The bandOverlaps.lobster file is generated during LOBSTER run. This indicates that the projected wave function is not completely orthonormalized. The maximal deviation values from the identity matrix is 0.4285 and there exists 0.1822 percent k-points above the deviation threshold 0.1. Please check the results of other quality checks like dos comparisons, charges , charge spillings before using the results for further analysis.",
"The atomic charge signs from Mulliken population analysis agree with the bond valence analysis.",
"The atomic charge signs from Loewdin population analysis agree with the bond valence analysis.",
Expand Down
41 changes: 39 additions & 2 deletions lobsterpy/test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def test_calc_quality_summary_NaCl(self, tmp_path):

ref_text = (
"The LOBSTER calculation used minimal basis. "
"The absolute and total charge spilling for the calculation are 0.3 and 5.58, respectively. "
"The absolute and total charge spilling for the calculation are 0.3 and 5.58 %, respectively. "
"The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is "
"generated during LOBSTER run. "
"The atomic charge signs from Mulliken population analysis agree with the bond valence analysis. "
Expand All @@ -291,6 +291,43 @@ def test_calc_quality_summary_NaCl(self, tmp_path):
assert calc_quality_text == ref_text
self.assert_is_finite_file(calc_quality_json_path)

def test_calc_quality_summary_NaCl_warnings(self, tmp_path):
os.chdir(TestDir / "TestData/NaCl_comp_range")
calc_quality_json_path = tmp_path / "calc_quality_json.json"
args = [
"calc-description",
"--bvacomp",
"--doscomp",
"--erange",
"-50",
"100",
"--calcqualityjson",
str(calc_quality_json_path),
]
captured_output = io.StringIO()
sys.stdout = captured_output

test = get_parser().parse_args(args)
run(test)

calc_quality_text = captured_output.getvalue().strip()

sys.stdout = sys.__stdout__

ref_text = (
"The LOBSTER calculation used minimal basis. "
"The absolute and total charge spilling for the calculation are 0.3 and 5.58 %, respectively. "
"The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is "
"generated during LOBSTER run. "
"The atomic charge signs from Mulliken population analysis agree with the bond valence analysis. "
"The atomic charge signs from Loewdin population analysis agree with the bond valence analysis. "
"The Tanimoto index from DOS comparisons in energy range between -5, 0 eV for s, p, summed orbitals "
"are : 0.9785, 0.9973, 0.9953."
)

assert calc_quality_text == ref_text
self.assert_is_finite_file(calc_quality_json_path)

def test_calc_quality_summary_K3Sb(self, tmp_path):
os.chdir(TestDir / "TestData/K3Sb")
calc_quality_json_path = tmp_path / "calc_quality_json.json"
Expand Down Expand Up @@ -318,7 +355,7 @@ def test_calc_quality_summary_K3Sb(self, tmp_path):

ref_text = (
"The LOBSTER calculation used minimal basis. "
"The absolute and total charge spilling for the calculation are 0.83 and 6.36, respectively. "
"The absolute and total charge spilling for the calculation are 0.83 and 6.36 %, respectively. "
"The bandOverlaps.lobster file is generated during LOBSTER run. This indicates that "
"the projected wave function is not completely orthonormalized, however the "
"maximal deviation values observed compared to the identity matrix is below the threshold 0.1. "
Expand Down

0 comments on commit f1cf2a6

Please sign in to comment.