From 50dd6cfce3a184616f7e91c04a5352259bac6e24 Mon Sep 17 00:00:00 2001 From: anaik Date: Fri, 29 Sep 2023 09:38:58 +0200 Subject: [PATCH 1/2] snakecase whichbonds arg and update tests --- lobsterpy/cli.py | 6 +-- lobsterpy/cohp/analyze.py | 44 +++++++++--------- lobsterpy/cohp/describe.py | 8 ++-- lobsterpy/cohp/test/test_analyze.py | 50 ++++++++++----------- lobsterpy/cohp/test/test_describe.py | 38 ++++++++-------- lobsterpy/featurize/core.py | 16 +++---- lobsterpy/featurize/test/test_batch.py | 2 +- lobsterpy/featurize/test/test_core.py | 10 ++--- lobsterpy/plotting/test/test_plotting.py | 8 ++-- lobsterpy/structuregraph/graph.py | 4 +- lobsterpy/structuregraph/test/test_graph.py | 2 +- 11 files changed, 92 insertions(+), 96 deletions(-) diff --git a/lobsterpy/cli.py b/lobsterpy/cli.py index f48a3114..c4e9efa5 100644 --- a/lobsterpy/cli.py +++ b/lobsterpy/cli.py @@ -666,16 +666,16 @@ def run(args): "autoplotia", ]: if args.allbonds: - whichbonds = "all" + which_bonds = "all" else: - whichbonds = "cation-anion" + which_bonds = "cation_anion" analyse = Analysis( path_to_poscar=args.poscar, path_to_charge=args.charge, path_to_cohpcar=args.cohpcar, path_to_icohplist=args.icohplist, - whichbonds=whichbonds, + which_bonds=which_bonds, are_coops=args.coops, are_cobis=args.cobis, noise_cutoff=args.noisecutoff, diff --git a/lobsterpy/cohp/analyze.py b/lobsterpy/cohp/analyze.py index a56ee950..933b42b8 100644 --- a/lobsterpy/cohp/analyze.py +++ b/lobsterpy/cohp/analyze.py @@ -51,7 +51,7 @@ class Analysis: spg: space group information structure: Structure object type_charge: which charges are considered here - whichbonds: which bonds will be considered in analysis + which_bonds: which bonds will be considered in analysis """ @@ -62,7 +62,7 @@ def __init__( path_to_cohpcar: str, path_to_charge: str | None = None, path_to_madelung: str | None = None, - whichbonds: str = "cation-anion", + which_bonds: str = "cation_anion", cutoff_icohp: float = 0.1, noise_cutoff: float = 0.1, summed_spins=True, @@ -83,7 +83,7 @@ def __init__( are_cobis : bool indicating if file contains COBI/ICOBI data are_coops : bool indicating if file contains COOP/ICOOP data noise_cutoff : float that sets the lower limit of icohps or icoops or icobis considered - whichbonds: selects which kind of bonds are analyzed. "cation-anion" is the default + which_bonds: selects which kind of bonds are analyzed. "cation-anion" is the default cutoff_icohp: only bonds that are stronger than cutoff_icohp*strongest ICOHP will be considered summed_spins: if true, spins will be summed type_charge: If no path_to_charge is given, Valences will be used. Otherwise, Mulliken charges. @@ -94,7 +94,7 @@ def __init__( self.path_to_poscar = path_to_poscar self.path_to_icohplist = path_to_icohplist self.path_to_cohpcar = path_to_cohpcar - self.whichbonds = whichbonds + self.which_bonds = which_bonds self.cutoff_icohp = cutoff_icohp self.path_to_charge = path_to_charge self.path_to_madelung = path_to_madelung @@ -142,7 +142,7 @@ def setup_env(self): self.set_equivalent_sites = list(set(equivalent_sites)) self.spg = symmetry_dataset["international"] - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": try: self.chemenv = LobsterNeighbors( filename_ICOHP=self.path_to_icohplist, @@ -167,7 +167,7 @@ def setup_env(self): " It looks like no cations are detected." ) raise err - elif self.whichbonds == "all": + elif self.which_bonds == "all": # raise ValueError("only cation anion bonds implemented so far") self.chemenv = LobsterNeighbors( filename_ICOHP=self.path_to_icohplist, @@ -187,11 +187,11 @@ def setup_env(self): # determine cations and anions try: - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": self.lse = self.chemenv.get_light_structure_environment( only_cation_environments=True ) - elif self.whichbonds == "all": + elif self.which_bonds == "all": self.lse = self.chemenv.get_light_structure_environment( only_cation_environments=False ) @@ -226,9 +226,9 @@ def __init__(self, chemenv, valences=None): [{"ce_symbol": None}] ) - if self.whichbonds == "all": + if self.which_bonds == "all": self.lse = Lse(self.chemenv.list_coords) - elif self.whichbonds == "cation-anion": + elif self.which_bonds == "cation_anion": # make a new list self.lse = Lse(self.chemenv.list_coords, self.chemenv.valences) @@ -240,7 +240,7 @@ def get_information_all_bonds(self, summed_spins=True): None """ - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": # this will only analyze cation anion bonds which simplifies the analysis self.seq_ineq_ions = [] self.seq_coord_ions = [] @@ -281,7 +281,7 @@ def get_information_all_bonds(self, summed_spins=True): self.seq_labels_cohps.append(aniontype_labels) self.seq_cohps.append(aniontype_cohps) - elif self.whichbonds == "all": + elif self.which_bonds == "all": # this will only analyze all bonds self.seq_ineq_ions = [] @@ -681,14 +681,14 @@ def set_condensed_bonding_analysis(self): """ self.condensed_bonding_analysis = {} # which icohps are considered - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": limit_icohps = self.chemenv._get_limit_from_extremum( self.chemenv.Icohpcollection, self.cutoff_icohp, adapt_extremum_to_add_cond=True, additional_condition=1, ) - elif self.whichbonds == "all": + elif self.which_bonds == "all": limit_icohps = self.chemenv._get_limit_from_extremum( self.chemenv.Icohpcollection, self.cutoff_icohp, @@ -700,9 +700,9 @@ def set_condensed_bonding_analysis(self): # set population type type_pop = self._get_pop_type() # how many inequivalent cations are in the structure - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": number_considered_ions = len(self.seq_ineq_ions) - elif self.whichbonds == "all": + elif self.which_bonds == "all": number_considered_ions = len(self.seq_ineq_ions) # what was the maximum bond lengths that was considered @@ -713,7 +713,7 @@ def set_condensed_bonding_analysis(self): # dictionary including bonding information for each site site_dict = {} - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": for ication, ce, cation_anion_infos, labels, cohps in zip( self.seq_ineq_ions, self.seq_coord_ions, @@ -755,7 +755,7 @@ def set_condensed_bonding_analysis(self): "charge": charge_list[ication], "relevant_bonds": cation_anion_infos[3], } - elif self.whichbonds == "all": + elif self.which_bonds == "all": for iion, ce, bond_infos, labels, cohps in zip( self.seq_ineq_ions, self.seq_coord_ions, @@ -798,7 +798,7 @@ def set_condensed_bonding_analysis(self): } if self.path_to_madelung is None: - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": # This sets the dictionary including the most important information on the compound self.condensed_bonding_analysis = { "formula": formula, @@ -808,7 +808,7 @@ def set_condensed_bonding_analysis(self): "sites": site_dict, "type_charges": self.type_charge, } - elif self.whichbonds == "all": + elif self.which_bonds == "all": self.condensed_bonding_analysis = { "formula": formula, "max_considered_bond_length": max_bond_lengths, @@ -826,7 +826,7 @@ def set_condensed_bonding_analysis(self): elif self.type_charge == "Löwdin": madelung_energy = madelung.madelungenergies_Loewdin # This sets the dictionary including the most important information on the compound - if self.whichbonds == "cation-anion": + if self.which_bonds == "cation_anion": self.condensed_bonding_analysis = { "formula": formula, "max_considered_bond_length": max_bond_lengths, @@ -836,7 +836,7 @@ def set_condensed_bonding_analysis(self): "type_charges": self.type_charge, "madelung_energy": madelung_energy, } - elif self.whichbonds == "all": + elif self.which_bonds == "all": self.condensed_bonding_analysis = { "formula": formula, "max_considered_bond_length": max_bond_lengths, diff --git a/lobsterpy/cohp/describe.py b/lobsterpy/cohp/describe.py index 57ca8f44..ba09ff6a 100644 --- a/lobsterpy/cohp/describe.py +++ b/lobsterpy/cohp/describe.py @@ -45,7 +45,7 @@ def set_description(self): type_pop = self.analysis_object._get_pop_type() # set units for populations units = " eV" if type_pop == "COHP" else "" - if self.analysis_object.whichbonds == "cation-anion": + if self.analysis_object.which_bonds == "cation_anion": relevant_cations = ", ".join( [ str(site.specie) + str(isite + 1) @@ -119,7 +119,7 @@ def set_description(self): + str(bonds) + " bonds." ) - elif self.analysis_object.whichbonds == "all": + elif self.analysis_object.which_bonds == "all": relevant_ions = ", ".join( [ str(site.specie) + str(isite + 1) @@ -236,9 +236,9 @@ def plot_cohps( """ seq_cohps = self.analysis_object.seq_cohps - if self.analysis_object.whichbonds == "cation-anion": + if self.analysis_object.which_bonds == "cation_anion": seq_ineq_cations = self.analysis_object.seq_ineq_ions - elif self.analysis_object.whichbonds == "all": + elif self.analysis_object.which_bonds == "all": seq_ineq_cations = self.analysis_object.seq_ineq_ions seq_labels = self.analysis_object.seq_labels_cohps structure = self.analysis_object.structure diff --git a/lobsterpy/cohp/test/test_analyze.py b/lobsterpy/cohp/test/test_analyze.py index 139f0d5e..85b8306f 100644 --- a/lobsterpy/cohp/test/test_analyze.py +++ b/lobsterpy/cohp/test/test_analyze.py @@ -16,7 +16,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -25,7 +25,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -34,7 +34,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COBICAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_cobis=True, @@ -45,7 +45,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, start=-4.0, ) @@ -55,7 +55,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=None, - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -65,7 +65,7 @@ def setUp(self): path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", path_to_madelung=TestDir / "TestData/NaCl/MadelungEnergies.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -74,7 +74,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTiO3/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/BaTiO3/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/BaTiO3/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -83,7 +83,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTaO2N1/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/BaTaO2N1/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/BaTaO2N1/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -92,7 +92,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTiO3/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/BaTiO3/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/BaTiO3/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.001, ) @@ -101,7 +101,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_distorted/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_distorted/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_distorted/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -110,7 +110,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_spin/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_spin/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_spin/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -119,7 +119,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) @@ -129,7 +129,7 @@ def setUp(self): path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", path_to_madelung=TestDir / "TestData/NaCl/MadelungEnergies.lobster", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) self.analyse_NaSi_madelung_all = Analysis( @@ -138,7 +138,7 @@ def setUp(self): path_to_icohplist=TestDir / "TestData/NaSi/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaSi/CHARGE.lobster", path_to_madelung=TestDir / "TestData/NaSi/MadelungEnergies.lobster", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) @@ -147,7 +147,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTaO2N1/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/BaTaO2N1/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/BaTaO2N1/CHARGE.lobster.gz", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.001, ) @@ -156,7 +156,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -165,7 +165,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, start=-5.5, ) @@ -175,7 +175,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/CdF/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/CdF/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, start=-4.0, ) @@ -185,7 +185,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF_comp_range/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/CdF_comp_range/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/CdF_comp_range/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -194,7 +194,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF_comp_range/COOPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/CdF_comp_range/ICOOPLIST.lobster.gz", path_to_charge=TestDir / "TestData/CdF_comp_range/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_coops=True, @@ -205,7 +205,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -214,7 +214,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) @@ -223,7 +223,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COBICAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOBILIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, noise_cutoff=0.001, are_cobis=True, @@ -238,7 +238,7 @@ def test_exception(self): path_to_cohpcar=TestDir / "TestData/BaTaO2N1/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/BaTaO2N1/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/BaTaO2N1/CHARGE.lobster.gz", - whichbonds="cation-cation", + which_bonds="cation_cation", cutoff_icohp=0.1, ) with self.assertRaises(ValueError) as err: @@ -247,7 +247,7 @@ def test_exception(self): path_to_cohpcar=TestDir / "TestData/C/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/C/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/C/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) self.assertEqual( diff --git a/lobsterpy/cohp/test/test_describe.py b/lobsterpy/cohp/test/test_describe.py index a22ad70e..d1dfe8f0 100644 --- a/lobsterpy/cohp/test/test_describe.py +++ b/lobsterpy/cohp/test/test_describe.py @@ -21,7 +21,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) self.describe_NaCl = Description(self.analyse_NaCl) @@ -31,7 +31,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=None, - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) self.describe_NaCl_valences = Description(self.analyse_NaCl_valences) @@ -41,7 +41,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTiO3/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/BaTiO3/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/BaTiO3/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -52,7 +52,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTaO2N1/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/BaTaO2N1/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/BaTaO2N1/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) self.describe_BaTaO2N1 = Description(self.analyse_BaTaO2N1) @@ -64,7 +64,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/CdF/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/CdF/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) self.describe_CdF = Description(self.analyse_CdF) @@ -74,7 +74,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_distorted/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_distorted/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_distorted/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -85,7 +85,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_spin/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_spin/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_spin/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, summed_spins=False, ) @@ -96,7 +96,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) @@ -108,7 +108,7 @@ def setUp(self): path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", path_to_madelung=TestDir / "TestData/NaCl/MadelungEnergies.lobster", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) @@ -119,7 +119,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COBICAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_cobis=True, @@ -134,7 +134,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF_comp_range/COOPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/CdF_comp_range/ICOOPLIST.lobster.gz", path_to_charge=TestDir / "TestData/CdF_comp_range/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_coops=True, @@ -150,7 +150,7 @@ def setUp(self): path_to_icohplist=TestDir / "TestData/NaSi/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaSi/CHARGE.lobster", path_to_madelung=TestDir / "TestData/NaSi/MadelungEnergies.lobster", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) @@ -161,7 +161,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) self.describe_NaSbF6 = Description(self.analyse_NaSbF6) @@ -171,7 +171,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, start=-5.5, ) @@ -183,7 +183,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, start=-4.0, ) @@ -195,7 +195,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/CdF/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/CdF/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, start=-4.0, ) @@ -208,7 +208,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, ) @@ -219,7 +219,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) @@ -231,7 +231,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CsH/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/CsH/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/CsH/CHARGE.lobster.gz", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, ) diff --git a/lobsterpy/featurize/core.py b/lobsterpy/featurize/core.py index d9e68bc1..ac1543b0 100644 --- a/lobsterpy/featurize/core.py +++ b/lobsterpy/featurize/core.py @@ -34,7 +34,7 @@ class to featurize lobsterpy data Args: path_to_lobster_calc: path containing lobster calc outputs path_to_json: path to lobster lightweight json - bonds: "all" or "cation-anion" bonds + bonds: "all" or "cation_anion" bonds Attributes: get_df: returns a pandas dataframe with relevant icohp statistical data as columns from lobsterpy automatic bonding analysis @@ -89,13 +89,13 @@ def get_df(self, ids: str | None = None) -> pd.DataFrame: bond = [] antibond = [] # extract lobsterpy icohp related data for bond type specified - # Results will differ for "all" and "cation-anion" mode. + # Results will differ for "all" and "cation_anion" mode. # In "all" bonds mode, the bonds will come up twice, also # cation-cation, anion-anion bonds will also be considered if self.bonds == "all": bond_type = "all_bonds" - elif self.bonds == "cation-anion": + elif self.bonds == "cation_anion": bond_type = "cation_anion_bonds" if ( @@ -172,7 +172,7 @@ def get_lobsterpy_cba_dict(path_to_lobster_calc: str, bonds: str) -> dict: Args: path_to_lobster_calc: path to lobsterpy lightweight json file - bonds: "all" or "cation-anion" bonds + bonds: "all" or "cation_anion" bonds Returns: Returns a dictionary with lobster summmarized bonding analysis data @@ -208,11 +208,7 @@ def get_lobsterpy_cba_dict(path_to_lobster_calc: str, bonds: str) -> dict: icohplist_path = req_files_lobsterpy.get("icohplist_path") which_bonds = bonds - - if which_bonds == "all": - bond_type = "all_bonds" - elif which_bonds == "cation-anion": - bond_type = "cation_anion_bonds" + bond_type = f"{which_bonds}_bonds" try: analyse = Analysis( @@ -222,7 +218,7 @@ def get_lobsterpy_cba_dict(path_to_lobster_calc: str, bonds: str) -> dict: path_to_charge=str(charge_path), summed_spins=False, # we will always use spin polarization here cutoff_icohp=0.10, - whichbonds=which_bonds, + which_bonds=which_bonds, ) data = {bond_type: {"lobsterpy_data": analyse.condensed_bonding_analysis}} diff --git a/lobsterpy/featurize/test/test_batch.py b/lobsterpy/featurize/test/test_batch.py index 2e3c4fb5..4169cd4b 100644 --- a/lobsterpy/featurize/test/test_batch.py +++ b/lobsterpy/featurize/test/test_batch.py @@ -59,7 +59,7 @@ def setUp(self): self.summary_featurize_with_json_antibonding = BatchSummaryFeaturizer( path_to_lobster_calcs=TestDir / "TestData/Featurizer_test_data/Lobster_calcs", - bonds="cation-anion", + bonds="cation_anion", path_to_jsons=TestDir / "TestData/Featurizer_test_data/JSONS", feature_type="antibonding", include_cobi_data=False, diff --git a/lobsterpy/featurize/test/test_core.py b/lobsterpy/featurize/test/test_core.py index 9d7fd9a6..cdfc68b4 100644 --- a/lobsterpy/featurize/test/test_core.py +++ b/lobsterpy/featurize/test/test_core.py @@ -16,7 +16,7 @@ def setUp(self): self.featurize_mp1249_json_ca = FeaturizeLobsterpy( path_to_json=TestDir / "TestData/JSONS/mp-1249.json.gz", - bonds="cation-anion", + bonds="cation_anion", ) self.featurize_mp1958_json = FeaturizeLobsterpy( path_to_json=TestDir / "TestData/JSONS/mp-1958.json.gz", bonds="all" @@ -486,27 +486,27 @@ def test_lobsterpy_featurize_exception(self): with self.assertRaises(Exception) as err: self.featurize_CsH_cation_anion = FeaturizeLobsterpy( - path_to_lobster_calc=TestDir / "TestData/CsH/", bonds="cation-anion" + path_to_lobster_calc=TestDir / "TestData/CsH/", bonds="cation_anion" ) _ = self.featurize_CsH_cation_anion.get_df() self.assertEqual( err.exception.__str__(), - "No cation-anion bonds detected for CsH structure. " + "No cation_anion bonds detected for CsH structure. " "Please switch to ´all´ bonds mode", ) with self.assertRaises(Exception) as err: self.featurize_C_cation_anion = FeaturizeLobsterpy( - path_to_lobster_calc=TestDir / "TestData/C/", bonds="cation-anion" + path_to_lobster_calc=TestDir / "TestData/C/", bonds="cation_anion" ) _ = self.featurize_C_cation_anion.get_df() self.assertEqual( err.exception.__str__(), - "No cation-anion bonds detected for C structure. " + "No cation_anion bonds detected for C structure. " "Please switch to ´all´ bonds mode", ) diff --git a/lobsterpy/plotting/test/test_plotting.py b/lobsterpy/plotting/test/test_plotting.py index 1548e296..96551ef9 100644 --- a/lobsterpy/plotting/test/test_plotting.py +++ b/lobsterpy/plotting/test/test_plotting.py @@ -27,7 +27,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, summed_spins=False, ) @@ -37,7 +37,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COBICAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - whichbonds="cation-anion", + which_bonds="cation_anion", cutoff_icohp=0.1, summed_spins=False, noise_cutoff=0.001, @@ -49,7 +49,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSi/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaSi/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaSi/CHARGE.lobster", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, summed_spins=True, ) @@ -59,7 +59,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - whichbonds="all", + which_bonds="all", cutoff_icohp=0.1, summed_spins=False, ) diff --git a/lobsterpy/structuregraph/graph.py b/lobsterpy/structuregraph/graph.py index 3a21343f..746a045d 100644 --- a/lobsterpy/structuregraph/graph.py +++ b/lobsterpy/structuregraph/graph.py @@ -81,7 +81,7 @@ def __init__( if self.which_bonds == "all": self.additional_condition = 0 - elif self.which_bonds == "cation-anion": + elif self.which_bonds == "cation_anion": self.additional_condition = 1 else: raise ValueError( @@ -145,7 +145,7 @@ def get_decorated_sg(self): path_to_poscar=self.path_to_poscar, path_to_icohplist=self.path_to_icohplist, path_to_madelung=self.path_to_madelung, - whichbonds=self.which_bonds, + which_bonds=self.which_bonds, cutoff_icohp=self.cutoff_icohp, ) diff --git a/lobsterpy/structuregraph/test/test_graph.py b/lobsterpy/structuregraph/test/test_graph.py index 86a8ff73..0a5a1a92 100644 --- a/lobsterpy/structuregraph/test/test_graph.py +++ b/lobsterpy/structuregraph/test/test_graph.py @@ -33,7 +33,7 @@ def setUp(self): path_to_icobilist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_madelung=TestDir / "TestData/NaCl_comp_range/MadelungEnergies.lobster.gz", - which_bonds="cation-anion", + which_bonds="cation_anion", start=None, ) From 30ac9e2be4212fec1abd712f089e898459e60ad4 Mon Sep 17 00:00:00 2001 From: anaik Date: Fri, 29 Sep 2023 16:19:07 +0200 Subject: [PATCH 2/2] fix input string for which_bonds as before --- lobsterpy/cli.py | 2 +- lobsterpy/cohp/analyze.py | 20 ++++++------ lobsterpy/cohp/describe.py | 4 +-- lobsterpy/cohp/test/test_analyze.py | 36 ++++++++++----------- lobsterpy/cohp/test/test_describe.py | 28 ++++++++-------- lobsterpy/featurize/core.py | 10 +++--- lobsterpy/featurize/test/test_batch.py | 2 +- lobsterpy/featurize/test/test_core.py | 10 +++--- lobsterpy/plotting/test/test_plotting.py | 4 +-- lobsterpy/structuregraph/graph.py | 2 +- lobsterpy/structuregraph/test/test_graph.py | 2 +- 11 files changed, 60 insertions(+), 60 deletions(-) diff --git a/lobsterpy/cli.py b/lobsterpy/cli.py index c4e9efa5..76ce83e8 100644 --- a/lobsterpy/cli.py +++ b/lobsterpy/cli.py @@ -668,7 +668,7 @@ def run(args): if args.allbonds: which_bonds = "all" else: - which_bonds = "cation_anion" + which_bonds = "cation-anion" analyse = Analysis( path_to_poscar=args.poscar, diff --git a/lobsterpy/cohp/analyze.py b/lobsterpy/cohp/analyze.py index 933b42b8..9a64f8a3 100644 --- a/lobsterpy/cohp/analyze.py +++ b/lobsterpy/cohp/analyze.py @@ -62,7 +62,7 @@ def __init__( path_to_cohpcar: str, path_to_charge: str | None = None, path_to_madelung: str | None = None, - which_bonds: str = "cation_anion", + which_bonds: str = "cation-anion", cutoff_icohp: float = 0.1, noise_cutoff: float = 0.1, summed_spins=True, @@ -142,7 +142,7 @@ def setup_env(self): self.set_equivalent_sites = list(set(equivalent_sites)) self.spg = symmetry_dataset["international"] - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": try: self.chemenv = LobsterNeighbors( filename_ICOHP=self.path_to_icohplist, @@ -187,7 +187,7 @@ def setup_env(self): # determine cations and anions try: - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": self.lse = self.chemenv.get_light_structure_environment( only_cation_environments=True ) @@ -228,7 +228,7 @@ def __init__(self, chemenv, valences=None): if self.which_bonds == "all": self.lse = Lse(self.chemenv.list_coords) - elif self.which_bonds == "cation_anion": + elif self.which_bonds == "cation-anion": # make a new list self.lse = Lse(self.chemenv.list_coords, self.chemenv.valences) @@ -240,7 +240,7 @@ def get_information_all_bonds(self, summed_spins=True): None """ - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": # this will only analyze cation anion bonds which simplifies the analysis self.seq_ineq_ions = [] self.seq_coord_ions = [] @@ -681,7 +681,7 @@ def set_condensed_bonding_analysis(self): """ self.condensed_bonding_analysis = {} # which icohps are considered - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": limit_icohps = self.chemenv._get_limit_from_extremum( self.chemenv.Icohpcollection, self.cutoff_icohp, @@ -700,7 +700,7 @@ def set_condensed_bonding_analysis(self): # set population type type_pop = self._get_pop_type() # how many inequivalent cations are in the structure - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": number_considered_ions = len(self.seq_ineq_ions) elif self.which_bonds == "all": number_considered_ions = len(self.seq_ineq_ions) @@ -713,7 +713,7 @@ def set_condensed_bonding_analysis(self): # dictionary including bonding information for each site site_dict = {} - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": for ication, ce, cation_anion_infos, labels, cohps in zip( self.seq_ineq_ions, self.seq_coord_ions, @@ -798,7 +798,7 @@ def set_condensed_bonding_analysis(self): } if self.path_to_madelung is None: - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": # This sets the dictionary including the most important information on the compound self.condensed_bonding_analysis = { "formula": formula, @@ -826,7 +826,7 @@ def set_condensed_bonding_analysis(self): elif self.type_charge == "Löwdin": madelung_energy = madelung.madelungenergies_Loewdin # This sets the dictionary including the most important information on the compound - if self.which_bonds == "cation_anion": + if self.which_bonds == "cation-anion": self.condensed_bonding_analysis = { "formula": formula, "max_considered_bond_length": max_bond_lengths, diff --git a/lobsterpy/cohp/describe.py b/lobsterpy/cohp/describe.py index ba09ff6a..672bb712 100644 --- a/lobsterpy/cohp/describe.py +++ b/lobsterpy/cohp/describe.py @@ -45,7 +45,7 @@ def set_description(self): type_pop = self.analysis_object._get_pop_type() # set units for populations units = " eV" if type_pop == "COHP" else "" - if self.analysis_object.which_bonds == "cation_anion": + if self.analysis_object.which_bonds == "cation-anion": relevant_cations = ", ".join( [ str(site.specie) + str(isite + 1) @@ -236,7 +236,7 @@ def plot_cohps( """ seq_cohps = self.analysis_object.seq_cohps - if self.analysis_object.which_bonds == "cation_anion": + if self.analysis_object.which_bonds == "cation-anion": seq_ineq_cations = self.analysis_object.seq_ineq_ions elif self.analysis_object.which_bonds == "all": seq_ineq_cations = self.analysis_object.seq_ineq_ions diff --git a/lobsterpy/cohp/test/test_analyze.py b/lobsterpy/cohp/test/test_analyze.py index 85b8306f..c6680319 100644 --- a/lobsterpy/cohp/test/test_analyze.py +++ b/lobsterpy/cohp/test/test_analyze.py @@ -16,7 +16,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -25,7 +25,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -34,7 +34,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COBICAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_cobis=True, @@ -45,7 +45,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, start=-4.0, ) @@ -55,7 +55,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=None, - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -65,7 +65,7 @@ def setUp(self): path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", path_to_madelung=TestDir / "TestData/NaCl/MadelungEnergies.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -74,7 +74,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTiO3/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/BaTiO3/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/BaTiO3/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -83,7 +83,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTaO2N1/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/BaTaO2N1/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/BaTaO2N1/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -92,7 +92,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTiO3/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/BaTiO3/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/BaTiO3/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.001, ) @@ -101,7 +101,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_distorted/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_distorted/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_distorted/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -110,7 +110,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_spin/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_spin/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_spin/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -156,7 +156,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -165,7 +165,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, start=-5.5, ) @@ -175,7 +175,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/CdF/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/CdF/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, start=-4.0, ) @@ -185,7 +185,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF_comp_range/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/CdF_comp_range/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/CdF_comp_range/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -194,7 +194,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF_comp_range/COOPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/CdF_comp_range/ICOOPLIST.lobster.gz", path_to_charge=TestDir / "TestData/CdF_comp_range/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_coops=True, @@ -205,7 +205,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -247,7 +247,7 @@ def test_exception(self): path_to_cohpcar=TestDir / "TestData/C/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/C/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/C/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) self.assertEqual( diff --git a/lobsterpy/cohp/test/test_describe.py b/lobsterpy/cohp/test/test_describe.py index d1dfe8f0..61d5bb7c 100644 --- a/lobsterpy/cohp/test/test_describe.py +++ b/lobsterpy/cohp/test/test_describe.py @@ -21,7 +21,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) self.describe_NaCl = Description(self.analyse_NaCl) @@ -31,7 +31,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=None, - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) self.describe_NaCl_valences = Description(self.analyse_NaCl_valences) @@ -41,7 +41,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTiO3/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/BaTiO3/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/BaTiO3/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -52,7 +52,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/BaTaO2N1/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/BaTaO2N1/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/BaTaO2N1/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) self.describe_BaTaO2N1 = Description(self.analyse_BaTaO2N1) @@ -64,7 +64,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/CdF/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/CdF/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) self.describe_CdF = Description(self.analyse_CdF) @@ -74,7 +74,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_distorted/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_distorted/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_distorted/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) @@ -85,7 +85,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_spin/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl_spin/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl_spin/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, summed_spins=False, ) @@ -119,7 +119,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COBICAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_cobis=True, @@ -134,7 +134,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF_comp_range/COOPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/CdF_comp_range/ICOOPLIST.lobster.gz", path_to_charge=TestDir / "TestData/CdF_comp_range/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, noise_cutoff=0.001, are_coops=True, @@ -161,7 +161,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) self.describe_NaSbF6 = Description(self.analyse_NaSbF6) @@ -171,7 +171,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaSbF6/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaSbF6/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/NaSbF6/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, start=-5.5, ) @@ -183,7 +183,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, start=-4.0, ) @@ -195,7 +195,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/CdF/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/CdF/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/CdF/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, start=-4.0, ) @@ -208,7 +208,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/K3Sb/COHPCAR.lobster.gz", path_to_icohplist=TestDir / "TestData/K3Sb/ICOHPLIST.lobster.gz", path_to_charge=TestDir / "TestData/K3Sb/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, ) diff --git a/lobsterpy/featurize/core.py b/lobsterpy/featurize/core.py index ac1543b0..5eef5569 100644 --- a/lobsterpy/featurize/core.py +++ b/lobsterpy/featurize/core.py @@ -34,7 +34,7 @@ class to featurize lobsterpy data Args: path_to_lobster_calc: path containing lobster calc outputs path_to_json: path to lobster lightweight json - bonds: "all" or "cation_anion" bonds + bonds: "all" or "cation-anion" bonds Attributes: get_df: returns a pandas dataframe with relevant icohp statistical data as columns from lobsterpy automatic bonding analysis @@ -89,13 +89,13 @@ def get_df(self, ids: str | None = None) -> pd.DataFrame: bond = [] antibond = [] # extract lobsterpy icohp related data for bond type specified - # Results will differ for "all" and "cation_anion" mode. + # Results will differ for "all" and "cation-anion" mode. # In "all" bonds mode, the bonds will come up twice, also # cation-cation, anion-anion bonds will also be considered if self.bonds == "all": bond_type = "all_bonds" - elif self.bonds == "cation_anion": + elif self.bonds == "cation-anion": bond_type = "cation_anion_bonds" if ( @@ -172,7 +172,7 @@ def get_lobsterpy_cba_dict(path_to_lobster_calc: str, bonds: str) -> dict: Args: path_to_lobster_calc: path to lobsterpy lightweight json file - bonds: "all" or "cation_anion" bonds + bonds: "all" or "cation-anion" bonds Returns: Returns a dictionary with lobster summmarized bonding analysis data @@ -207,7 +207,7 @@ def get_lobsterpy_cba_dict(path_to_lobster_calc: str, bonds: str) -> dict: structure_path = req_files_lobsterpy.get("structure_path") icohplist_path = req_files_lobsterpy.get("icohplist_path") - which_bonds = bonds + which_bonds = bonds.replace("-", "_") bond_type = f"{which_bonds}_bonds" try: diff --git a/lobsterpy/featurize/test/test_batch.py b/lobsterpy/featurize/test/test_batch.py index 4169cd4b..2e3c4fb5 100644 --- a/lobsterpy/featurize/test/test_batch.py +++ b/lobsterpy/featurize/test/test_batch.py @@ -59,7 +59,7 @@ def setUp(self): self.summary_featurize_with_json_antibonding = BatchSummaryFeaturizer( path_to_lobster_calcs=TestDir / "TestData/Featurizer_test_data/Lobster_calcs", - bonds="cation_anion", + bonds="cation-anion", path_to_jsons=TestDir / "TestData/Featurizer_test_data/JSONS", feature_type="antibonding", include_cobi_data=False, diff --git a/lobsterpy/featurize/test/test_core.py b/lobsterpy/featurize/test/test_core.py index cdfc68b4..9d7fd9a6 100644 --- a/lobsterpy/featurize/test/test_core.py +++ b/lobsterpy/featurize/test/test_core.py @@ -16,7 +16,7 @@ def setUp(self): self.featurize_mp1249_json_ca = FeaturizeLobsterpy( path_to_json=TestDir / "TestData/JSONS/mp-1249.json.gz", - bonds="cation_anion", + bonds="cation-anion", ) self.featurize_mp1958_json = FeaturizeLobsterpy( path_to_json=TestDir / "TestData/JSONS/mp-1958.json.gz", bonds="all" @@ -486,27 +486,27 @@ def test_lobsterpy_featurize_exception(self): with self.assertRaises(Exception) as err: self.featurize_CsH_cation_anion = FeaturizeLobsterpy( - path_to_lobster_calc=TestDir / "TestData/CsH/", bonds="cation_anion" + path_to_lobster_calc=TestDir / "TestData/CsH/", bonds="cation-anion" ) _ = self.featurize_CsH_cation_anion.get_df() self.assertEqual( err.exception.__str__(), - "No cation_anion bonds detected for CsH structure. " + "No cation-anion bonds detected for CsH structure. " "Please switch to ´all´ bonds mode", ) with self.assertRaises(Exception) as err: self.featurize_C_cation_anion = FeaturizeLobsterpy( - path_to_lobster_calc=TestDir / "TestData/C/", bonds="cation_anion" + path_to_lobster_calc=TestDir / "TestData/C/", bonds="cation-anion" ) _ = self.featurize_C_cation_anion.get_df() self.assertEqual( err.exception.__str__(), - "No cation_anion bonds detected for C structure. " + "No cation-anion bonds detected for C structure. " "Please switch to ´all´ bonds mode", ) diff --git a/lobsterpy/plotting/test/test_plotting.py b/lobsterpy/plotting/test/test_plotting.py index 96551ef9..10a9b02a 100644 --- a/lobsterpy/plotting/test/test_plotting.py +++ b/lobsterpy/plotting/test/test_plotting.py @@ -27,7 +27,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl/COHPCAR.lobster", path_to_icohplist=TestDir / "TestData/NaCl/ICOHPLIST.lobster", path_to_charge=TestDir / "TestData/NaCl/CHARGE.lobster", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, summed_spins=False, ) @@ -37,7 +37,7 @@ def setUp(self): path_to_cohpcar=TestDir / "TestData/NaCl_comp_range/COBICAR.lobster.gz", path_to_icohplist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_charge=TestDir / "TestData/NaCl_comp_range/CHARGE.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", cutoff_icohp=0.1, summed_spins=False, noise_cutoff=0.001, diff --git a/lobsterpy/structuregraph/graph.py b/lobsterpy/structuregraph/graph.py index 746a045d..55769dce 100644 --- a/lobsterpy/structuregraph/graph.py +++ b/lobsterpy/structuregraph/graph.py @@ -81,7 +81,7 @@ def __init__( if self.which_bonds == "all": self.additional_condition = 0 - elif self.which_bonds == "cation_anion": + elif self.which_bonds == "cation-anion": self.additional_condition = 1 else: raise ValueError( diff --git a/lobsterpy/structuregraph/test/test_graph.py b/lobsterpy/structuregraph/test/test_graph.py index 0a5a1a92..86a8ff73 100644 --- a/lobsterpy/structuregraph/test/test_graph.py +++ b/lobsterpy/structuregraph/test/test_graph.py @@ -33,7 +33,7 @@ def setUp(self): path_to_icobilist=TestDir / "TestData/NaCl_comp_range/ICOBILIST.lobster.gz", path_to_madelung=TestDir / "TestData/NaCl_comp_range/MadelungEnergies.lobster.gz", - which_bonds="cation_anion", + which_bonds="cation-anion", start=None, )