From b0732231fa3a81a0a79221cecbfa1a474625daec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:30:01 +0000 Subject: [PATCH 1/2] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.20 → v0.16.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.20...v0.16.1) - [github.com/pre-commit/mirrors-mypy: v2.1.0 → v2.3.0](https://github.com/pre-commit/mirrors-mypy/compare/v2.1.0...v2.3.0) - [github.com/codespell-project/codespell: v2.4.2 → v2.4.3](https://github.com/codespell-project/codespell/compare/v2.4.2...v2.4.3) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 35a0b832..98500de8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ default_language_version: python: python3 repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.20 + rev: v0.16.1 hooks: - id: ruff args: [--fix] @@ -39,7 +39,7 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - repo: https://github.com/pre-commit/mirrors-mypy - rev: v2.1.0 + rev: v2.3.0 hooks: - id: mypy files: lobsterpy/.* @@ -48,7 +48,7 @@ repos: - types-pkg_resources==0.1.2 - types-paramiko - repo: https://github.com/codespell-project/codespell - rev: v2.4.2 + rev: v2.4.3 hooks: - id: codespell stages: [pre-commit, commit-msg] From 04c6e43328f969f270e3ae1d05e5f428e92c49f4 Mon Sep 17 00:00:00 2001 From: Aakash Ashok Naik <91958822+naik-aakash@users.noreply.github.com> Date: Wed, 5 Aug 2026 09:07:08 +0000 Subject: [PATCH 2/2] apply ruff linit fix --- tests/cohp/test_describe.py | 194 ++++++++++++++++++++++------------ tests/quality/test_analyze.py | 92 ++++++++++------ 2 files changed, 184 insertions(+), 102 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index e8d55673..34e83f98 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -176,112 +176,168 @@ def test_text( ): assert describe_cdf.text == [ "The compound CdF2 has 1 symmetry-independent cation(s) with relevant cation-anion interactions: Cd1.", - "Cd1 has a cubic (CN=8) coordination environment. It has 8 Cd-F (mean ICOHP: -0.62 eV, " - "38.289 percent antibonding interaction below EFermi) bonds.", + ( + "Cd1 has a cubic (CN=8) coordination environment. It has 8 Cd-F (mean ICOHP: -0.62 eV, " + "38.289 percent antibonding interaction below EFermi) bonds." + ), ] assert describe_nacl.text == [ "The compound NaCl has 1 symmetry-independent cation(s) with relevant cation-anion interactions: Na1.", - "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-Cl (mean ICOHP: -0.57 eV," - " 1.754 percent antibonding interaction below EFermi) bonds.", + ( + "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-Cl (mean ICOHP: -0.57 eV," + " 1.754 percent antibonding interaction below EFermi) bonds." + ), ] assert describe_nasbf6.text == [ - "The compound NaSbF6 has 2 symmetry-independent cation(s) with relevant cation-anion interactions: " - "Na1, Sb2.", - "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-F (mean ICOHP: -0.61 eV, " - "1.592 percent antibonding interaction below EFermi) bonds.", - "Sb2 has an octahedral (CN=6) coordination environment. It has 6 Sb-F (mean ICOHP: -5.45 eV, " - "0.0 percent antibonding interaction below EFermi) bonds.", + ( + "The compound NaSbF6 has 2 symmetry-independent cation(s) with relevant cation-anion interactions: " + "Na1, Sb2." + ), + ( + "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-F (mean ICOHP: -0.61 eV, " + "1.592 percent antibonding interaction below EFermi) bonds." + ), + ( + "Sb2 has an octahedral (CN=6) coordination environment. It has 6 Sb-F (mean ICOHP: -5.45 eV, " + "0.0 percent antibonding interaction below EFermi) bonds." + ), ] assert describe_nasbf6_anbd.text == [ - "The compound NaSbF6 has 2 symmetry-independent cation(s) with relevant cation-anion " - "interactions: Na1, Sb2.", - "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-F (mean ICOHP: -0.61 eV, " - "0.0 percent antibonding interaction below EFermi) bonds.", - "Sb2 has an octahedral (CN=6) coordination environment. It has 6 Sb-F (mean ICOHP: -5.45 eV, " - "0.0 percent antibonding interaction below EFermi) bonds.", + ( + "The compound NaSbF6 has 2 symmetry-independent cation(s) with relevant cation-anion " + "interactions: Na1, Sb2." + ), + ( + "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-F (mean ICOHP: -0.61 eV, " + "0.0 percent antibonding interaction below EFermi) bonds." + ), + ( + "Sb2 has an octahedral (CN=6) coordination environment. It has 6 Sb-F (mean ICOHP: -5.45 eV, " + "0.0 percent antibonding interaction below EFermi) bonds." + ), ] assert describe_nacl_nan.text == [ "The compound NaCl has 1 symmetry-independent cation(s) with relevant cation-anion interactions: Na1.", - "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-Cl (mean ICOHP: -0.57 eV, " - "0.0 percent antibonding interaction below EFermi) bonds.", + ( + "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-Cl (mean ICOHP: -0.57 eV, " + "0.0 percent antibonding interaction below EFermi) bonds." + ), ] assert describe_cdf_anbd.text == [ "The compound CdF2 has 1 symmetry-independent cation(s) with relevant cation-anion interactions: Cd1.", - "Cd1 has a cubic (CN=8) coordination environment. It has 8 Cd-F (mean ICOHP: -0.62 eV, " - "100.0 percent antibonding interaction below EFermi) bonds.", + ( + "Cd1 has a cubic (CN=8) coordination environment. It has 8 Cd-F (mean ICOHP: -0.62 eV, " + "100.0 percent antibonding interaction below EFermi) bonds." + ), ] assert describe_k3sb.text == [ "The compound K3Sb has 2 symmetry-independent cation(s) with relevant cation-anion interactions: K1, K2.", - "K1 has an octahedral (CN=6) coordination environment. It has 6 K-Sb (mean ICOHP: -0.14 eV, " - "1.163 percent antibonding interaction below EFermi) bonds.", - "K2 has a tetrahedral (CN=4) coordination environment. It has 4 K-Sb (mean ICOHP: -0.36 eV, " - "4.403 percent antibonding interaction below EFermi) bonds.", + ( + "K1 has an octahedral (CN=6) coordination environment. It has 6 K-Sb (mean ICOHP: -0.14 eV, " + "1.163 percent antibonding interaction below EFermi) bonds." + ), + ( + "K2 has a tetrahedral (CN=4) coordination environment. It has 4 K-Sb (mean ICOHP: -0.36 eV, " + "4.403 percent antibonding interaction below EFermi) bonds." + ), ] assert describe_k3sb_all.text == [ "The compound K3Sb has 3 symmetry-independent atoms(s) with relevant bonds: K1, K2, Sb4.", - "K1 has a 14-fold coordination environment. It has 8 K-K (mean ICOHP: -0.37 eV, 17.219 percent " - "antibonding interaction below EFermi), and 6 K-Sb (mean ICOHP: -0.14 eV, 1.163 percent " - "antibonding interaction below EFermi) bonds.", - "K2 has a 14-fold coordination environment. It has 10 K-K (mean ICOHP: -0.22 eV, 17.073 " - "percent antibonding interaction below EFermi), and 4 K-Sb (mean ICOHP: -0.36 eV, 4.403 " - "percent antibonding interaction below EFermi) bonds.", - "Sb4 has a 14-fold coordination environment. It has 14 Sb-K (mean ICOHP: -0.27 eV, 2.771 " - "percent antibonding interaction below EFermi) bonds.", + ( + "K1 has a 14-fold coordination environment. It has 8 K-K (mean ICOHP: -0.37 eV, 17.219 percent " + "antibonding interaction below EFermi), and 6 K-Sb (mean ICOHP: -0.14 eV, 1.163 percent " + "antibonding interaction below EFermi) bonds." + ), + ( + "K2 has a 14-fold coordination environment. It has 10 K-K (mean ICOHP: -0.22 eV, 17.073 " + "percent antibonding interaction below EFermi), and 4 K-Sb (mean ICOHP: -0.36 eV, 4.403 " + "percent antibonding interaction below EFermi) bonds." + ), + ( + "Sb4 has a 14-fold coordination environment. It has 14 Sb-K (mean ICOHP: -0.27 eV, 2.771 " + "percent antibonding interaction below EFermi) bonds." + ), ] assert describe_csh_all.text == [ "The compound CsH has 1 symmetry-independent atoms(s) with relevant bonds: Cs1.", - "Cs1 has a 18-fold coordination environment. It has 18 Cs-Cs (mean ICOHP: -0.49 eV, 18.741 " - "percent antibonding interaction below EFermi) bonds.", + ( + "Cs1 has a 18-fold coordination environment. It has 18 Cs-Cs (mean ICOHP: -0.49 eV, 18.741 " + "percent antibonding interaction below EFermi) bonds." + ), ] assert describe_batio3_orb.text == [ "The compound BaTiO3 has 1 symmetry-independent cation(s) with relevant cation-anion interactions: Ti2.", - "Ti2 has an octahedral (CN=6) coordination environment. It has 6 Ti-O (mean ICOHP: -3.54 eV, " - "0.985 percent antibonding interaction below EFermi) bonds.", - "In the 6 Ti-O bonds, relative to the summed ICOHPs, the maximum bonding contribution is " - "from the Ti(3d)-O(2p) orbital, contributing 88.0 percent, whereas the maximum " - "antibonding contribution is from the Ti(3p)-O(2p) orbital, contributing 37.0 percent.", + ( + "Ti2 has an octahedral (CN=6) coordination environment. It has 6 Ti-O (mean ICOHP: -3.54 eV, " + "0.985 percent antibonding interaction below EFermi) bonds." + ), + ( + "In the 6 Ti-O bonds, relative to the summed ICOHPs, the maximum bonding contribution is " + "from the Ti(3d)-O(2p) orbital, contributing 88.0 percent, whereas the maximum " + "antibonding contribution is from the Ti(3p)-O(2p) orbital, contributing 37.0 percent." + ), ] assert describe_c_orb.text == [ "The compound C has 1 symmetry-independent atoms(s) with relevant bonds: C1.", - "C1 has a tetrahedral (CN=4) coordination environment. " - "It has 4 C-C (mean ICOHP: -9.59 eV, 0.0 percent antibonding interaction below EFermi) bonds.", - "In the 4 C-C bonds, relative to the summed ICOHPs, the maximum bonding contribution is " - "from the C(2p)-C(2p) orbital, contributing 44.0 percent, whereas no significant " - "antibonding contribution is found in this bond.", + ( + "C1 has a tetrahedral (CN=4) coordination environment. " + "It has 4 C-C (mean ICOHP: -9.59 eV, 0.0 percent antibonding interaction below EFermi) bonds." + ), + ( + "In the 4 C-C bonds, relative to the summed ICOHPs, the maximum bonding contribution is " + "from the C(2p)-C(2p) orbital, contributing 44.0 percent, whereas no significant " + "antibonding contribution is found in this bond." + ), ] assert describe_nasbf6_orb.text == [ "The compound NaSbF6 has 3 symmetry-independent atoms(s) with relevant bonds: Na1, Sb2, F3.", - "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-F (mean ICOHP: -0.61 eV, 1.592 percent " - "antibonding interaction below EFermi) bonds.", - "In the 6 Na-F bonds, relative to the summed ICOHPs, the maximum bonding contribution is from " - "the Na(3s)-F(2s) orbital, " - "contributing 67.0 percent, whereas the maximum antibonding contribution is from the Na(2p)-F(2s) orbital, " - "contributing 38.0 percent.", - "Sb2 has an octahedral (CN=6) coordination environment. It has 6 Sb-F (mean ICOHP: -5.45 eV, 0.0 percent " - "antibonding interaction below EFermi) bonds.", - "In the 6 Sb-F bonds, relative to the summed ICOHPs, the maximum bonding contribution is from the " - "Sb(5p)-F(2s) orbital, contributing 42.0 percent, whereas " - "no significant antibonding contribution is found in this bond.", - "F3 has a linear (CN=2) coordination environment. It has 1 F-Sb (mean ICOHP: -5.45 eV, 0.0" - " percent antibonding " - "interaction below EFermi), and 1 F-Na (mean ICOHP: -0.61 eV, 1.587 percent antibonding" - " interaction below EFermi) bonds.", - "In the 1 F-Sb bond, relative to the summed ICOHPs, the maximum bonding contribution is from the" - " F(2s)-Sb(5p) orbital, contributing 42.0 percent, whereas no significant antibonding contribution is" - " found in this bond. In the 1 F-Na bond, relative to the summed ICOHPs, the maximum bonding " - "contribution is from the F(2s)-Na(3s) orbital, contributing 68.0 percent," - " whereas the maximum antibonding contribution is from F(2s)-Na(2p) and F(2p)-Na(2p) orbitals," - " contributing 36.0 and 36.0 percent, respectively.", + ( + "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-F (mean ICOHP: -0.61 eV, 1.592 " + "percent antibonding interaction below EFermi) bonds." + ), + ( + "In the 6 Na-F bonds, relative to the summed ICOHPs, the maximum bonding contribution is from " + "the Na(3s)-F(2s) orbital, " + "contributing 67.0 percent, whereas the maximum antibonding contribution is from the Na(2p)-F(2s) " + "orbital, contributing 38.0 percent." + ), + ( + "Sb2 has an octahedral (CN=6) coordination environment. It has 6 Sb-F (mean ICOHP: -5.45 eV, 0.0 " + "percent antibonding interaction below EFermi) bonds." + ), + ( + "In the 6 Sb-F bonds, relative to the summed ICOHPs, the maximum bonding contribution is from the " + "Sb(5p)-F(2s) orbital, contributing 42.0 percent, whereas " + "no significant antibonding contribution is found in this bond." + ), + ( + "F3 has a linear (CN=2) coordination environment. It has 1 F-Sb (mean ICOHP: -5.45 eV, 0.0" + " percent antibonding " + "interaction below EFermi), and 1 F-Na (mean ICOHP: -0.61 eV, 1.587 percent antibonding" + " interaction below EFermi) bonds." + ), + ( + "In the 1 F-Sb bond, relative to the summed ICOHPs, the maximum bonding contribution is from the" + " F(2s)-Sb(5p) orbital, contributing 42.0 percent, whereas no significant antibonding contribution is" + " found in this bond. In the 1 F-Na bond, relative to the summed ICOHPs, the maximum bonding " + "contribution is from the F(2s)-Na(3s) orbital, contributing 68.0 percent," + " whereas the maximum antibonding contribution is from F(2s)-Na(2p) and F(2p)-Na(2p) orbitals," + " contributing 36.0 and 36.0 percent, respectively." + ), ] assert describe_cdf_comp_range_coop.text == [ "The compound CdF2 has 1 symmetry-independent cation(s) with relevant cation-anion interactions: Cd1.", - "Cd1 has a cubic (CN=8) coordination environment. It has 8 Cd-F (mean ICOOP: 0.01, 40.0 percent " - "antibonding interaction below EFermi) bonds.", + ( + "Cd1 has a cubic (CN=8) coordination environment. It has 8 Cd-F (mean ICOOP: 0.01, 40.0 percent " + "antibonding interaction below EFermi) bonds." + ), ] assert describe_nacl_comp_range_cobi.text == [ "The compound NaCl has 1 symmetry-independent cation(s) with relevant cation-anion interactions: Na1.", - "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-Cl (mean ICOBI: 0.08, 0.0 percent " - "antibonding interaction below EFermi) bonds.", + ( + "Na1 has an octahedral (CN=6) coordination environment. It has 6 Na-Cl (mean ICOBI: 0.08, 0.0 percent " + "antibonding interaction below EFermi) bonds." + ), ] def test_msonable(self, describe_nacl, describe_cdf): diff --git a/tests/quality/test_analyze.py b/tests/quality/test_analyze.py index a3651a7a..43487353 100644 --- a/tests/quality/test_analyze.py +++ b/tests/quality/test_analyze.py @@ -210,13 +210,17 @@ def test_calc_quality_description_text(self): assert calc_quality_k3sb_des == [ "The LOBSTER calculation used minimal basis.", "The absolute and total charge spilling for the calculation is 0.83 and 6.36 %, respectively.", - "The bandOverlaps.lobster file is generated during the 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 of 0.1.", + ( + "The bandOverlaps.lobster file is generated during the 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 of 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.", - "The Tanimoto index from DOS comparisons in the energy range between -20, 0 eV for s, p," - " summed orbitals are: 0.8532, 0.9481, 0.9275.", + ( + "The Tanimoto index from DOS comparisons in the energy range between -20, 0 eV for s, p," + " summed orbitals are: 0.8532, 0.9481, 0.9275." + ), ] calc_quality_csh_des = Description.get_calc_quality_description(calc_quality_CsH) @@ -227,11 +231,13 @@ def test_calc_quality_description_text(self): == [ "The LOBSTER calculation used minimal basis.", "The absolute and total charge spilling for the calculation is 3.01 and 13.73 %, respectively.", - "The bandOverlaps.lobster file is generated during the LOBSTER run. This indicates that the projected " - "wave function is not completely orthonormalized. " - "The maximal deviation value from the identity matrix is 0.4285, and there are 0.1822 percent " - "k-points above the deviation threshold of 0.1. Please check the results of other quality checks " - "like dos comparisons, charges, charge spillings before using the results for further analysis.", + ( + "The bandOverlaps.lobster file is generated during the LOBSTER run. This indicates that the " + "projected wave function is not completely orthonormalized. " + "The maximal deviation value from the identity matrix is 0.4285, and there are 0.1822 percent " + "k-points above the deviation threshold of 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.", ] @@ -259,19 +265,29 @@ def test_warnings(self): actual_warnings = [str(warning.message) for warning in w] expected_warnings = [ - "This method is being deprecated and will be removed on 30-06-2026. " - "Please use `lobsterpy.quality.LobsterCalcQuality.from_files()` or " - "`lobsterpy.quality.LobsterCalcQuality.from_directory()` instead.", + ( + "This method is being deprecated and will be removed on 30-06-2026. " + "Please use `lobsterpy.quality.LobsterCalcQuality.from_files()` or " + "`lobsterpy.quality.LobsterCalcQuality.from_directory()` instead." + ), "Consider using DOSCAR.LSO.lobster, as non LSO DOS from LOBSTER can have negative DOS values", - "Minimum energy range requested for DOS comparisons is not available in VASP or LOBSTER calculation. " - "Thus, setting `min_e` to the minimum possible value of -15 eV", - "Maximum energy range requested for DOS comparisons is not available in VASP or LOBSTER calculation. " - "Thus, setting `max_e` to the maximum possible value of 5 eV", - "Number of bins requested for DOS comparisons is larger than the number of points in the energy interval. " - "Thus, setting `n_bins` to 107.", - "Input DOS files have very few points in the energy interval and thus comparisons will not be reliable. " - "Please rerun the calculations with higher number of DOS points. " - "Set NEDOS and COHPSteps tags to >= 2000 in VASP and LOBSTER calculations, respectively.", + ( + "Minimum energy range requested for DOS comparisons is not available in VASP or LOBSTER calculation. " + "Thus, setting `min_e` to the minimum possible value of -15 eV" + ), + ( + "Maximum energy range requested for DOS comparisons is not available in VASP or LOBSTER calculation. " + "Thus, setting `max_e` to the maximum possible value of 5 eV" + ), + ( + "Number of bins requested for DOS comparisons is larger than the number of points in the energy " + "interval. Thus, setting `n_bins` to 107." + ), + ( + "Input DOS files have very few points in the energy interval and thus comparisons will not be " + "reliable. Please rerun the calculations with higher number of DOS points. " + "Set NEDOS and COHPSteps tags to >= 2000 in VASP and LOBSTER calculations, respectively." + ), ] for actual, expected in zip(actual_warnings, expected_warnings): @@ -282,10 +298,14 @@ def test_warnings(self): assert calc_des == [ "The LOBSTER calculation used minimal basis.", "The absolute and total charge spilling for the calculation is 2.255 and 12.72 %, respectively.", - "The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is " - "generated during the LOBSTER run.", - "The Tanimoto index from DOS comparisons in the energy range between -15, 5 eV for s, p, summed orbitals " - "are: 0.6712, 0.8113, 0.8064.", + ( + "The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is " + "generated during the LOBSTER run." + ), + ( + "The Tanimoto index from DOS comparisons in the energy range between -15, 5 eV for s, p, summed " + "orbitals are: 0.6712, 0.8113, 0.8064." + ), ] with warnings.catch_warnings(record=True) as w2: @@ -305,8 +325,10 @@ def test_warnings(self): assert calc_des2 == [ "The LOBSTER calculation used minimal basis.", "The absolute and total charge spilling for the calculation is 0.98 and 8.93 %, respectively.", - "The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is " - "generated during the LOBSTER run.", + ( + "The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is " + "generated during the LOBSTER run." + ), "Oxidation states from BVA analyzer cannot be determined. Thus BVA charge comparison is not conducted.", ] @@ -329,12 +351,16 @@ def test_warnings(self): calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) assert calc_des3 == [ - "Consider rerunning the calculation with the minimum basis as well. " - "Choosing a larger basis set is only recommended if you see a significant improvement of " - "the charge spilling.", + ( + "Consider rerunning the calculation with the minimum basis as well. " + "Choosing a larger basis set is only recommended if you see a significant improvement of " + "the charge spilling." + ), "The absolute and total charge spilling for the calculation is 1.48 and 13.99 %, respectively.", - "The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is generated " - "during the LOBSTER run.", + ( + "The projected wave function is completely orthonormalized as no bandOverlaps.lobster file is " + "generated during the LOBSTER run." + ), "The atomic charge signs from Mulliken population analysis do not agree with the bond valence analysis.", "The atomic charge signs from Loewdin population analysis do not agree with the bond valence analysis.", ]