diff --git a/tests/io/orca/inpgen/test_multxyz.py b/tests/io/orca/inpgen/test_multxyz.py index f67bd57..0fe5656 100644 --- a/tests/io/orca/inpgen/test_multxyz.py +++ b/tests/io/orca/inpgen/test_multxyz.py @@ -49,5 +49,11 @@ def test_multxyz_num(mult_xyz): def test_multxyz_struct(exp_inpgen): + """ + Multiply the values in the inpgen dictionary. + + Args: + exp_inpgen: write your description + """ waex.cookies.gen_base(f"{exp_inpgen}") pass diff --git a/tests/io/orca/inpgen/test_orcainpgen.py b/tests/io/orca/inpgen/test_orcainpgen.py index 555dd82..e1b4350 100644 --- a/tests/io/orca/inpgen/test_orcainpgen.py +++ b/tests/io/orca/inpgen/test_orcainpgen.py @@ -34,6 +34,12 @@ def prep_inpgen(tmpdir_factory): def test_keywords(datadir): + """ + Test that ymlt has the same keywords as expected + + Args: + datadir: write your description + """ ymlt = waio.inp.inpGenerator(datadir / "orcaBlockKey.yml") string = f""" ! NUMGRAD @@ -48,6 +54,12 @@ def test_keywords(datadir): def test_blocks(datadir): + """ + Test that ymlt. blocks matches expected blocks + + Args: + datadir: write your description + """ ymlt = waio.inp.inpGenerator(datadir / "orcaBlockKey.yml") string = """ %method @@ -70,6 +82,12 @@ def test_blocks(datadir): def test_geom_constraint(prep_inpgen): + """ + Test that yaml file has the expected geometry lines + + Args: + prep_inpgen: write your description + """ string = f""" %geom Scan @@ -101,6 +119,12 @@ def test_geom_constraint(prep_inpgen): def test_geom_scaniter(prep_inpgen): + """ + Test that yaml file has the expected geometry lines + + Args: + prep_inpgen: write your description + """ string = f""" %geom Scan @@ -129,6 +153,12 @@ def test_geom_scaniter(prep_inpgen): def test_geom_maxiter(prep_inpgen): + """ + Test that yaml file has maxiter geometry lines + + Args: + prep_inpgen: write your description + """ string = f""" %geom maxiter = 300 @@ -147,20 +177,44 @@ def test_geom_maxiter(prep_inpgen): def test_brokensym(prep_inpgen): + """ + Test broken symtabs. + + Args: + prep_inpgen: write your description + """ waex.cookies.gen_base(f"{prep_inpgen}/expbrsym.yml") pass def test_nobrsym(prep_inpgen): + """ + This test is a little lame but it s not a good idea to use this. + + Args: + prep_inpgen: write your description + """ waex.cookies.gen_base(f"{prep_inpgen}/nbrsym.yml") pass def test_viz(datadir): + """ + Test that the Viz file is properly formatted. + + Args: + datadir: write your description + """ pass def test_geom_scans(datadir): + """ + Test that ymlt. geomlines matches the expected geometry lines. + + Args: + datadir: write your description + """ ymlt = waio.inp.inpGenerator(datadir / "orcaGeom.yml") string = f""" %geom diff --git a/tests/io/orca/singles/test_sp.py b/tests/io/orca/singles/test_sp.py index 311e79e..b0f18b6 100644 --- a/tests/io/orca/singles/test_sp.py +++ b/tests/io/orca/singles/test_sp.py @@ -19,12 +19,24 @@ def test_orca_get_sp_e(datadir): + """ + Test that the orca - Vis functionality works correctly. + + Args: + datadir: write your description + """ sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") np.testing.assert_almost_equal(sEnerg.fin_sp_e.m, -1.01010039) pass def test_orca_runinfo(datadir): + """ + Test that the runinfo object is a dict of orca run information. + + Args: + datadir: write your description + """ se = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") se.runinfo = waio.orca.getRunInfo(Path("H2_test/QCISD/spin_01/ENERGY/3-21G/")) assert se.runinfo == { @@ -43,6 +55,12 @@ def test_orca_runinfo(datadir): def test_orca_mdci_e_bounds(datadir): + """ + Test that a single energy surface with a lower bound is within the range of the DCI. + + Args: + datadir: write your description + """ sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") with pytest.raises(ValueError): sEnerg.single_energy_surface(npoints=34) @@ -50,6 +68,12 @@ def test_orca_mdci_e_bounds(datadir): def test_orca_energ_error(datadir): + """ + Test that an error is raised when using Orca. + + Args: + datadir: write your description + """ sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") with pytest.raises(NotImplementedError): sEnerg.single_energy_surface(etype="Squid") @@ -57,6 +81,12 @@ def test_orca_energ_error(datadir): def test_orca_energ_empty(datadir): + """ + Test that an orca energie is empty. + + Args: + datadir: write your description + """ warnings.filterwarnings("ignore") sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_uhf.out") with pytest.raises(ValueError): @@ -203,6 +233,12 @@ def test_orca_mdci_e_mtrip_yvals(datadir): def test_mult_energy_surf(datadir): + """ + Mult the single energy surface with multiple energy surfaces. + + Args: + datadir: write your description + """ sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") eDat = sEnerg.single_energy_surface("MDCI w/o Triples", 33) eDatMDCI = sEnerg.single_energy_surface("MDCI") @@ -214,6 +250,12 @@ def test_mult_energy_surf(datadir): def test_mult_energy_surf_subset(datadir): + """ + Subset of the energies in a sub - set. + + Args: + datadir: write your description + """ sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") eDatAll = sEnerg.mult_energy_surface(etype=["MDCI", "SCF Energy"]) assert "Actual Energy" not in eDatAll.columns @@ -223,6 +265,12 @@ def test_mult_energy_surf_subset(datadir): def test_mult_energy_surf_single(datadir): + """ + Multiplier of energy surfaces with single energy surfaces + + Args: + datadir: write your description + """ sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") eDatSingleL = sEnerg.mult_energy_surface(etype=["MDCI"]) eDatMDCI = sEnerg.single_energy_surface("MDCI") @@ -238,6 +286,12 @@ def test_mult_energy_surf_single(datadir): def test_orca_single_chargepop(datadir): + """ + Test the orca - vis single - population analysis. + + Args: + datadir: write your description + """ spop = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") sdat = spop.single_population_analysis() assert sdat.shape == (4, 5) @@ -249,6 +303,12 @@ def test_orca_single_chargepop(datadir): def test_orca_single_fullpop(datadir): + """ + Test for orca - single fullpopulation analysis. + + Args: + datadir: write your description + """ spop = waio.orca.orcaVis(ofile=datadir / "orca_uhf.out") sdat = spop.single_population_analysis() assert sdat.shape == (2, 6) @@ -261,6 +321,12 @@ def test_orca_single_fullpop(datadir): def test_orca_nstep_pop(datadir): + """ + Test the orca - vis single population analysis. + + Args: + datadir: write your description + """ spop = waio.orca.orcaVis(ofile=datadir / "ch3f_3ang_b3lyp.out") popdat = spop.single_population_analysis() assert popdat.step.max() == 2 @@ -276,6 +342,12 @@ def test_orca_nstep_pop(datadir): def test_orca_mult_chargepop(datadir): + """ + Test the multi - population analysis of the orca - vis data. + + Args: + datadir: write your description + """ spop = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out") sdat = spop.mult_population_analysis() assert sdat.shape == (8, 10) @@ -284,6 +356,12 @@ def test_orca_mult_chargepop(datadir): def test_orca_mult_fullpop(datadir): + """ + Variant of orca. orcaVis. mult_population_analysis. + + Args: + datadir: write your description + """ spop = waio.orca.orcaVis(ofile=datadir / "orca_uhf.out") sdat = spop.mult_population_analysis() assert sdat.shape == (4, 11) @@ -298,6 +376,12 @@ def test_orca_mult_fullpop(datadir): def test_orca_irspec(datadir): + """ + Test the IR spec of the orca - Vis dataset. + + Args: + datadir: write your description + """ spop = waio.orca.orcaVis(ofile=datadir / "b3lyp_6311g88_h2o.out") sdat = spop.ir_spec() assert sdat.shape == (3, 11) @@ -316,6 +400,12 @@ def test_orca_irspec(datadir): def test_orca_vpt2(datadir): + """ + Test the vpt2 transitions of orca via waio. orcaVis + + Args: + datadir: write your description + """ spop = waio.orca.orcaVis(ofile=datadir / "orcaVPT2.out") sdat = spop.vpt2_transitions() assert sdat.shape == (3, 9) @@ -348,6 +438,12 @@ def test_orca_vpt2(datadir): def test_calc_htst(datadir): + """ + Calculate the HST using the orca library. + + Args: + datadir: write your description + """ prod = waio.orca.orcaVis(ofile=datadir / "orcaProduct.out") react = waio.orca.orcaVis(ofile=datadir / "orcaReactant.out") ts = waio.orca.orcaVis(ofile=datadir / "orcaTS.out") diff --git a/tests/io/orca/test_io.py b/tests/io/orca/test_io.py index fbd405f..c2aab1f 100644 --- a/tests/io/orca/test_io.py +++ b/tests/io/orca/test_io.py @@ -11,6 +11,12 @@ def test_orca_genEBDA(datadir): + """ + Test that the genEBDA method works. + + Args: + datadir: write your description + """ magnitude = [ -38.652, -38.853, @@ -44,6 +50,12 @@ def test_orca_genEBDA(datadir): def test_get_final_sp_energy(datadir): + """ + Test the get_final_sp_energy method of the orca expt module. + + Args: + datadir: write your description + """ expt = waio.orca.orcaExp(expfolder=datadir / "h2") fse = expt.get_final_sp_energy() fse.shape == (27, 6) @@ -100,6 +112,12 @@ def test_get_final_sp_energy(datadir): def test_get_energy_surface_shape(datadir): + """ + Test that the get_energy_surface method works correctly with the shape of the energy surface. + + Args: + datadir: write your description + """ expt = waio.orca.orcaExp(expfolder=datadir / "h2") edat = expt.get_energy_surface() assert list(edat.theory.unique()) == [ @@ -125,6 +143,12 @@ def test_get_energy_surface_shape(datadir): @pytest.mark.filterwarnings("ignore::UserWarning") def test_get_energy_surface_empty(datadir): + """ + Test for get_energy_surface with an empty energy surface. + + Args: + datadir: write your description + """ expt = waio.orca.orcaExp(expfolder=datadir / "h2") with pytest.raises(ValueError): expt.get_energy_surface(etype=["MDCI", "Actual Energy"]) @@ -132,6 +156,12 @@ def test_get_energy_surface_empty(datadir): def test_get_energy_surface_shape_more(datadir): + """ + Test that the get_energy_surface method works with more shapes. + + Args: + datadir: write your description + """ otheory = ["RHF", "RHF MP2", "UHF", "UHF MP2", "QCISD(T)"] expt = waio.orca.orcaExp( expfolder=datadir / "multiword_energy", order_theory=otheory @@ -167,6 +197,12 @@ def test_get_energy_surface_shape_more(datadir): def test_get_pop(datadir): + """ + Test that population data is consistent with get_population method. + + Args: + datadir: write your description + """ oth = ["UHF", "UKS BLYP", "UKS B3LYP"] expt = waio.orca.orcaExp(expfolder=datadir / "multxyz_pop", order_theory=oth) popdat = expt.get_population() @@ -201,6 +237,12 @@ def test_get_pop(datadir): def test_get_ir_freq(datadir): + """ + Test the get_ir_freq method of the orcaExp class. + + Args: + datadir: write your description + """ oth = ["HF", "MP2", "B3LYP"] expt = waio.orca.orcaExp(expfolder=datadir / "ir_spec", order_theory=oth) vdat = expt.get_ir_spec() @@ -215,6 +257,12 @@ def test_get_ir_freq(datadir): def test_vpt2_transitions(datadir): + """ + Test that the VPT2 transitions are stored in a transition matrix + + Args: + datadir: write your description + """ oth = ["HF", "MP2", "B3LYP"] expt = waio.orca.orcaExp(expfolder=datadir / "vpt2_h2o", order_theory=oth) vdat = expt.get_vpt2_transitions() diff --git a/tests/io/xyz/test_xyz.py b/tests/io/xyz/test_xyz.py index cfc2b6f..a183687 100644 --- a/tests/io/xyz/test_xyz.py +++ b/tests/io/xyz/test_xyz.py @@ -5,6 +5,12 @@ def test_xyz(datadir): + """ + Test that the xyz file is properly formatted. + + Args: + datadir: write your description + """ sx = waio.xyz.xyzIO(datadir / "h2mol.xyz") assert sx.comment_line == "XYZ file generated by Avogadro.\n" sx.comment_line = "new" @@ -43,18 +49,36 @@ def test_write_xyz(tmp_path, datadir): def test_slugxyz(datadir): + """ + Test slugxyz. xyzIO. slug. + + Args: + datadir: write your description + """ sx = waio.xyz.xyzIO(datadir / "h2mol.xyz") assert sx.slug == "H2_h2mol" pass def test_sysxyz(datadir): + """ + Test that the xyzio system is the same as the one produced by the io module. + + Args: + datadir: write your description + """ sx = waio.xyz.xyzIO(datadir / "h2mol.xyz") assert sx.system == "H2" pass def test_counts(datadir): + """ + Test that counts are set to 2. + + Args: + datadir: write your description + """ sx = waio.xyz.xyzIO(datadir / "h2mol.xyz") assert sx.counts == {"H": 2} pass diff --git a/wailord/io/inp.py b/wailord/io/inp.py index c1b89da..54ce83d 100644 --- a/wailord/io/inp.py +++ b/wailord/io/inp.py @@ -55,6 +55,13 @@ class inpGenerator: def __init__(self, filename): + """ + Initialize the object. + + Args: + self: write your description + filename: write your description + """ self.qc = None self.xyz = [] self.xyzpath = None @@ -73,6 +80,12 @@ def __init__(self, filename): self.scripts = [] def __repr__(self): + """ + Representation of the configuration. + + Args: + self: write your description + """ return f"{self.konfik.show_config()}" def read_yml(self): @@ -272,6 +285,13 @@ def parse_blocks(self, blocks): return "".join(blines) def parse_keywords(self, keywords): + """ + Parse keywords into a string. + + Args: + self: write your description + keywords: write your description + """ keylines = [] for kl in keywords: keylines.append(f"\n! {kl}") @@ -288,6 +308,13 @@ def parse_yml(self): pass def parse_viz(self, viz): + """ + Parses the viz object and returns a string with the appropriate formatting. + + Args: + self: write your description + viz: write your description + """ if viz.chemcraft is True: string = """ @@ -300,6 +327,13 @@ def parse_viz(self, viz): return textwrap.dedent(string) def parse_scf(self, scf): + """ + Parse a single SCF file. + + Args: + self: write your description + scf: write your description + """ textlines = [] textlines.append("\n%scf\n") if "brokensym" in scf: @@ -337,6 +371,13 @@ def parse_params(self, params): return "".join(textlines) def params_slot(self, thing): + """ + Returns the xyzblock and comment for a slot of a type. + + Args: + self: write your description + thing: write your description + """ if not "xyz" in thing or thing["xyz"] is not True: raise TypeError("Currently only supports xyz") atype, anum, axis, name = itemgetter("atype", "anum", "axis", "name")(thing) @@ -351,6 +392,14 @@ def params_slot(self, thing): return xyzblock, comment def params_value(self, thing, comment): + """ + Return the value of the parameters of a thing. + + Args: + self: write your description + thing: write your description + comment: write your description + """ name, val = itemgetter("name", "value")(thing) return f"\t{name} = {val} {comment}\n" @@ -387,6 +436,12 @@ def genharness(self, basename, slow=False): pass def parse_qc(self): + """ + Parse the QC options. + + Args: + self: write your description + """ qcList = list( itertt.chain(self.qc.style, self.qc.calculations, self.qc.basis_sets) ) @@ -516,10 +571,23 @@ class simpleInput: """ Base class for representing the simple input line""" def __init__(self, data): + """ + Initialize the tag from data. + + Args: + self: write your description + data: write your description + """ self.contents = None return def __repr__(self): + """ + Return a string representation of the object. + + Args: + self: write your description + """ return f"!{contents}" @@ -527,11 +595,24 @@ class blockInput: """Base class representing block inputs""" def __init__(self, data): + """ + Initialize the parser with the given data. + + Args: + self: write your description + data: write your description + """ self.keyword = None self.lines = None return def __repr__(self): + """ + Return a string representation of the file. + + Args: + self: write your description + """ string = f""" %block {keyword} {lines} @@ -544,11 +625,24 @@ class coordBlock: """Base class for the coordinate block""" def __init__(self, data): + """ + Initialize the parser with the given data. + + Args: + self: write your description + data: write your description + """ self.keyword = None self.lines = None return def __repr__(self): + """ + Return a string representation of the file. + + Args: + self: write your description + """ string = f""" *block {keyword} {lines} diff --git a/wailord/io/orca.py b/wailord/io/orca.py index 70c56d6..2fb373b 100644 --- a/wailord/io/orca.py +++ b/wailord/io/orca.py @@ -348,6 +348,12 @@ def __init__( self.handle_exp(expfolder) def __repr__(self): + """ + Return a string representation of the order. + + Args: + self: write your description + """ string = f""" Experiment: {self.inpconf} Outputs: {self.orclist} @@ -576,9 +582,22 @@ def __init__(self, ofile): self.get_final_e() def __repr__(self): + """ + Return a repr of the object. + + Args: + self: write your description + """ return f"{self.ofile}" def get_evals(self, ofile): + """ + Get the number of evals from the ofile. + + Args: + self: write your description + ofile: write your description + """ with open(self.ofile) as of: flines = of.readlines() for line in flines: @@ -587,6 +606,13 @@ def get_evals(self, ofile): return def get_final_e(self, dat=False): + """ + Read the final e from the ofile file. + + Args: + self: write your description + dat: write your description + """ with open(self.ofile) as of: fInp = of.read() try: @@ -603,6 +629,12 @@ def get_final_e(self, dat=False): pass def final_sp_e(self): + """ + Run info for final SP e. + + Args: + self: write your description + """ erow = self.runinfo erow["final_sp_energy"] = self.fin_sp_e.m erow["unit"] = self.fin_sp_e.u diff --git a/wailord/io/xyz.py b/wailord/io/xyz.py index c236c63..c975e25 100644 --- a/wailord/io/xyz.py +++ b/wailord/io/xyz.py @@ -52,6 +52,12 @@ class xyzVisitor(NodeVisitor): """This class extends NodeVisitor""" def __init__(self): + """ + Initialize the object. + + Args: + self: write your description + """ self.natoms = None self.coord_block = None self.clines = [] @@ -59,6 +65,12 @@ def __init__(self): self.meta = None def __repr__(self): + """ + Representation of the object. + + Args: + self: write your description + """ return f"{self.meta}" def visit_meta(self, node, visited_children): @@ -92,6 +104,14 @@ def visit_atype(self, node, visited_children): return node.text def generic_visit(self, node, visited_children): + """ + Return the node s text or the children of the node. + + Args: + self: write your description + node: write your description + visited_children: write your description + """ return node.text or visited_children @@ -99,6 +119,13 @@ class xyzIO: """This class handles xyz files at a user level""" def __init__(self, filename): + """ + Reads the file and creates the object. + + Args: + self: write your description + filename: write your description + """ self.filename = filename self.comment_line = "Generated by wailord" self.xyzdat = None @@ -108,9 +135,21 @@ def __init__(self, filename): self.read() def __repr__(self): + """ + Represent the file. + + Args: + self: write your description + """ return f"XYZ file {self.filename}" def read(self): + """ + Reads the XYZ file and parses the xyz data. + + Args: + self: write your description + """ with open(self.filename) as fp: dat = fp.readlines() self.comment_line = dat[1] @@ -128,15 +167,35 @@ def read(self): @property def comment_line(self): + """ + Return the comment line. + + Args: + self: write your description + """ return self._comment_line @comment_line.setter def comment_line(self, cl): + """ + Set the comment line. + + Args: + self: write your description + cl: write your description + """ if len(cl.split("\n")) > 1: cl.replace("\n", " ") self._comment_line = cl def write(self, outname): + """ + Write the data to a file. + + Args: + self: write your description + outname: write your description + """ with open(outname, "w") as op: # Recreate the comment line outdat = str(self.xyzdat).split("\n") diff --git a/wailord_templates/basicExperiment/hooks/pre_gen_project.py b/wailord_templates/basicExperiment/hooks/pre_gen_project.py index 574c55b..99133ac 100755 --- a/wailord_templates/basicExperiment/hooks/pre_gen_project.py +++ b/wailord_templates/basicExperiment/hooks/pre_gen_project.py @@ -5,6 +5,11 @@ def main(): + """ + Main entry point for wailord. + + Args: + """ try: import wailord except ImportError as error: