Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Nov 16, 2023
1 parent 0be7cb2 commit c641b8f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 96 deletions.
21 changes: 0 additions & 21 deletions tests/io/orca/singles/test_sp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
def test_orca_get_sp_e(datadir):
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):
Expand All @@ -35,7 +34,6 @@ def test_orca_runinfo(datadir):
"theory": "QCISD",
"slug": "H2_test",
}
pass


##########################
Expand All @@ -47,14 +45,12 @@ def test_orca_mdci_e_bounds(datadir):
sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out")
with pytest.raises(ValueError):
sEnerg.single_energy_surface(npoints=34)
pass


def test_orca_energ_error(datadir):
sEnerg = waio.orca.orcaVis(ofile=datadir / "orca_qcisdt.out")
with pytest.raises(NotImplementedError):
sEnerg.single_energy_surface(etype="Squid")
pass


def test_orca_energ_empty(datadir):
Expand All @@ -64,7 +60,6 @@ def test_orca_energ_empty(datadir):
sEnerg.single_energy_surface("MDCI", 33)
with pytest.raises(ValueError):
sEnerg.single_energy_surface("MDCI w/o Triples")
pass


def test_orca_mdci_e_xvals(datadir):
Expand All @@ -76,7 +71,6 @@ def test_orca_mdci_e_xvals(datadir):
blength,
np.linspace(0.4, 2, 33),
)
pass


def test_orca_mdci_e_yvals(datadir):
Expand Down Expand Up @@ -125,7 +119,6 @@ def test_orca_mdci_e_yvals(datadir):
energy,
exp_e,
)
pass


def test_orca_mdci_e_mtrip_xvals(datadir):
Expand All @@ -137,7 +130,6 @@ def test_orca_mdci_e_mtrip_xvals(datadir):
blength,
np.linspace(0.4, 2, 33),
)
pass


def test_orca_mdci_e_mtrip_energy_evals(datadir):
Expand All @@ -146,7 +138,6 @@ def test_orca_mdci_e_mtrip_energy_evals(datadir):
eDat = sEnerg.single_energy_surface(npoints=33)
eDat1 = sEnerg.single_energy_surface()
pd.testing.assert_frame_equal(eDat, eDat1)
pass


def test_orca_mdci_e_mtrip_yvals(datadir):
Expand Down Expand Up @@ -195,7 +186,6 @@ def test_orca_mdci_e_mtrip_yvals(datadir):
energy,
exp_e,
)
pass


############################
Expand All @@ -211,7 +201,6 @@ def test_mult_energy_surf(datadir):
pd.testing.assert_frame_equal(eDat, eDatAll[["bond_length", "MDCI w/o Triples"]])
pd.testing.assert_frame_equal(eDatMDCI, eDatAll[["bond_length", "MDCI"]])
assert len(eDatAll) == len(eDat)
pass


def test_mult_energy_surf_subset(datadir):
Expand All @@ -220,7 +209,6 @@ def test_mult_energy_surf_subset(datadir):
assert "Actual Energy" not in eDatAll.columns
assert "MDCI" in eDatAll.columns
assert "SCF Energy" in eDatAll.columns
pass


def test_mult_energy_surf_single(datadir):
Expand All @@ -230,7 +218,6 @@ def test_mult_energy_surf_single(datadir):
pd.testing.assert_frame_equal(eDatMDCI, eDatSingleL.loc[:, ["bond_length", "MDCI"]])
eDatSingle = sEnerg.mult_energy_surface(etype="MDCI")
pd.testing.assert_frame_equal(eDatMDCI, eDatSingle.loc[:, ["bond_length", "MDCI"]])
pass


##############################
Expand All @@ -246,7 +233,6 @@ def test_orca_single_chargepop(datadir):
sdat2 = spop.single_population_analysis("Loewdin")
assert sdat2.shape == (4, 5)
np.testing.assert_equal(sdat2.pcharge.to_numpy(), np.zeros(4))
pass


def test_orca_single_fullpop(datadir):
Expand All @@ -258,7 +244,6 @@ def test_orca_single_fullpop(datadir):
sdat2 = spop.single_population_analysis("Loewdin")
assert sdat2.shape == (2, 6)
np.testing.assert_equal(sdat2.pcharge.to_numpy(), np.zeros(2))
pass


def test_orca_nstep_pop(datadir):
Expand All @@ -268,7 +253,6 @@ def test_orca_nstep_pop(datadir):
assert (popdat >> si.filter(_.step == 1)).shape == (
popdat >> si.filter(_.step == 2)
).shape
pass


################################
Expand All @@ -281,7 +265,6 @@ def test_orca_mult_chargepop(datadir):
sdat = spop.mult_population_analysis()
assert sdat.shape == (8, 10)
np.testing.assert_equal(sdat.pcharge.to_numpy(), np.zeros(8))
pass


def test_orca_mult_fullpop(datadir):
Expand All @@ -290,7 +273,6 @@ def test_orca_mult_fullpop(datadir):
assert sdat.shape == (4, 11)
np.testing.assert_equal(sdat.pcharge.to_numpy(), np.zeros(4))
np.testing.assert_equal(sdat.pspin.to_numpy(), np.zeros(4))
pass


###############
Expand All @@ -308,7 +290,6 @@ def test_orca_irspec(datadir):
sdat.freq.pint.m.to_numpy(), np.array([1639.47, 3807.28, 3903.73])
)
np.testing.assert_equal(sdat.Mode.to_numpy(), np.array([6, 7, 8]))
pass


######################
Expand All @@ -326,7 +307,6 @@ def test_orca_vpt2(datadir):
sdat.harmonic_freq.pint.m.to_numpy(), np.array([1638.78, 3808.09, 3904.51])
)
np.testing.assert_equal(sdat.Mode.to_numpy(), np.array([1, 2, 3]))
pass


#########################
Expand Down Expand Up @@ -360,4 +340,3 @@ def test_calc_htst(datadir):
assert kf.u == "1/second"
np.testing.assert_almost_equal(kf.m, 2.80583587e-07)
np.testing.assert_almost_equal(kb.m, 3.31522447e-29)
pass
7 changes: 0 additions & 7 deletions tests/io/orca/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def test_get_final_sp_energy(datadir):
dtype=object,
),
)
pass


##############################
Expand Down Expand Up @@ -121,15 +120,13 @@ def test_get_energy_surface_shape(datadir):
assert len(edat[edat.isin(["3-21G"]).any(axis=1)]) == 3 * 33 #: 3 levels of theory
assert len(edat[edat.isin(["UHF"]).any(axis=1)]) == 9 * 33 #: 9 basis sets
assert edat.shape == (891, 8) #: Rows = basis (9) * theory (3) * npoints (33)
pass


@pytest.mark.filterwarnings("ignore::UserWarning")
def test_get_energy_surface_empty(datadir):
expt = waio.orca.orcaExp(expfolder=datadir / "h2")
with pytest.raises(ValueError):
expt.get_energy_surface(etype=["MDCI", "Actual Energy"])
pass


def test_get_energy_surface_shape_more(datadir):
Expand Down Expand Up @@ -159,7 +156,6 @@ def test_get_energy_surface_shape_more(datadir):
edat.theory.value_counts().to_numpy(),
np.repeat(33, 5),
)
pass


#######################
Expand Down Expand Up @@ -193,7 +189,6 @@ def test_get_pop(datadir):
popdat.theory.value_counts().to_numpy(),
np.array([60, 50, 40]),
)
pass


###############
Expand All @@ -207,7 +202,6 @@ def test_get_ir_freq(datadir):
vdat = expt.get_ir_spec()
assert vdat.shape == (63, 11)
assert (vdat >> si.filter(_.slug == "O1H2_h2o")).shape == (9, 11)
pass


######################
Expand All @@ -220,4 +214,3 @@ def test_vpt2_transitions(datadir):
expt = waio.orca.orcaExp(expfolder=datadir / "vpt2_h2o", order_theory=oth)
vdat = expt.get_vpt2_transitions()
assert vdat.shape == (9, 9)
pass
11 changes: 5 additions & 6 deletions wailord/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ def __init__(self, *args, **kwargs):
self[key] = DotDict(self[key])

def __getitem__(self, key):
if isinstance(key, str):
try:
return super().__getitem__(key)
except KeyError:
raise MissingVariableError(f"No such variable '{key}' exists") from None
else:
if not isinstance(key, str):
raise TypeError("Key must be a string")
try:
return super().__getitem__(key)
except KeyError:
raise MissingVariableError(f"No such variable '{key}' exists") from None

def __setitem__(self, key, value):
if isinstance(value, dict) and not isinstance(value, DotDict):
Expand Down
6 changes: 1 addition & 5 deletions wailord/exp/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@

def gen_base(filen=None, /, template="basicExperiment", *, absolute=False):
"""Generate a base template"""
if absolute:
template = str(template)
else:
template = str(TEMPLATE_DIR / template)

template = str(template) if absolute else str(TEMPLATE_DIR / template)
if filen is not None:
with open(filen, "r") as ymlfile:
config = yaml.safe_load(ymlfile)
Expand Down
Loading

0 comments on commit c641b8f

Please sign in to comment.