From f1cf2a6ee7e58a60596fd46131619f60faf178c4 Mon Sep 17 00:00:00 2001 From: anaik Date: Wed, 16 Aug 2023 17:06:15 +0200 Subject: [PATCH] increase coverage, added % symbol to calc qualtiy text --- lobsterpy/cohp/describe.py | 2 +- lobsterpy/cohp/test/test_describe.py | 4 +-- lobsterpy/test/test_cli.py | 41 ++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/lobsterpy/cohp/describe.py b/lobsterpy/cohp/describe.py index 4b73bddf..49622fb0 100644 --- a/lobsterpy/cohp/describe.py +++ b/lobsterpy/cohp/describe.py @@ -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"], diff --git a/lobsterpy/cohp/test/test_describe.py b/lobsterpy/cohp/test/test_describe.py index 48b79b57..d12681e8 100644 --- a/lobsterpy/cohp/test/test_describe.py +++ b/lobsterpy/cohp/test/test_describe.py @@ -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.", @@ -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.", diff --git a/lobsterpy/test/test_cli.py b/lobsterpy/test/test_cli.py index 0f6875cc..9db14c33 100644 --- a/lobsterpy/test/test_cli.py +++ b/lobsterpy/test/test_cli.py @@ -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. " @@ -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" @@ -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. "