Skip to content

Commit

Permalink
Removing commented out testing
Browse files Browse the repository at this point in the history
  • Loading branch information
benrich37 committed Nov 11, 2024
1 parent 68bb469 commit 82fd73f
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 250 deletions.
4 changes: 1 addition & 3 deletions tests/io/jdftx/test_jdftxinfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def test_JDFTXInfile_set_values(val_key: str, val: Any):
@pytest.mark.parametrize(
("val_key", "val"),
[
# ("fluid-solvent", "H2O 0.5"), # Causes issues with the list representation
("fluid-solvent", "H2O"),
("dump", "End DOS"),
("dump", "End DOS BandEigs"),
Expand Down Expand Up @@ -127,9 +126,8 @@ def test_JDFTXInfile_expected_exceptions():
value = {"blockSize": 1, "nOuterVxx": "barbie"}
err_str = str(f"The {tag} tag with value:\n{value}\ncould not be fixed!")
with pytest.raises(ValueError, match=re.escape(err_str)):
# Cannot set item without calling validate_tags
# Implicitly tests validate_tags
jif[tag] = value
# jif.validate_tags()
jif2 = jif.copy()
jif2.update({tag: value})
with pytest.raises(ValueError, match=re.escape(err_str)):
Expand Down
120 changes: 0 additions & 120 deletions tests/io/jdftx/test_jdftxoutfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,123 +53,3 @@ def test_JDFTXOutfile_fromfile(filename: Path, known: dict):
)
def test_JDFTXOutfile_fromfile_simple(filename: Path, known: dict):
jdftxoutfile_fromfile_matches_known_simple(filename, known)


empty_slice_exception_varnames = [
"prefix",
"jstrucs",
"jsettings_fluid",
"jsettings_electronic",
"jsettings_lattice",
"jsettings_ionic",
"xc_func",
"lattice_initial",
"lattice_final",
"lattice",
"a",
"b",
"c",
"fftgrid",
"geom_opt",
"geom_opt_type",
"efermi",
"egap",
"emin",
"emax",
"homo",
"lumo",
"homo_filling",
"lumo_filling",
"is_metal",
"etype",
"broadening_type",
"broadening",
"kgrid",
"truncation_type",
"truncation_radius",
"pwcut",
"rhocut",
"pp_type",
"total_electrons",
"semicore_electrons",
"valence_electrons",
"total_electrons_uncharged",
"semicore_electrons_uncharged",
"valence_electrons_uncharged",
"nbands",
"atom_elements",
"atom_elements_int",
"atom_types",
"spintype",
"nspin",
"nat",
"atom_coords_initial",
"atom_coords_final",
"atom_coords",
"has_solvation",
"fluid",
"is_gc",
"eopt_type",
"elecmindata",
"stress",
"strain",
"nstep",
"e",
"grad_k",
"alpha",
"linmin",
"nelectrons",
"abs_magneticmoment",
"tot_magneticmoment",
"mu",
"elec_nstep",
"elec_e",
"elec_grad_k",
"elec_alpha",
"elec_linmin",
]


# @pytest.mark.parametrize(
# ("dummy_filename", "none_exceptions"),
# [
# (
# ex_files_dir / Path("example_sp.out"),
# [
# "nstep",
# "stress",
# "strain",
# "linmin",
# "alpha",
# "truncation_radius",
# "grad_k",
# "abs_magneticmoment",
# "tot_magneticmoment",
# "elec_grad_k",
# "elec_alpha",
# "elec_linmin",
# ],
# )
# ],
# )
# def test_JDFTXOutfile_expected_exceptions_empty_slices(
# dummy_filename: PathLike,
# none_exceptions: list[str],
# ):
# for var in empty_slice_exception_varnames:
# expected_exceptions_empty_slices_test_varname(dummy_filename, var, none_exceptions)


# def expected_exceptions_empty_slices_test_varname(jout_filename: str, varname: str, none_exceptions: list[str]):
# jout = JDFTXOutfile.from_file(jout_filename)
# # First test that the attribute can be called
# val = getattr(jout, varname)
# # Next test it was properly called, or that its None if None is expected (but not both)
# v1 = bool(val is not None)
# v2 = bool(varname in none_exceptions)
# assert v1 != v2
# # assert bool(val is not None) != bool(val in none_exceptions)
# # Next test the error when slices is empty
# jout.slices = []
# with pytest.raises(AttributeError):
# getattr(jout, varname)
7 changes: 0 additions & 7 deletions tests/io/jdftx/test_jdftxoutfileslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def test_jdftxoutfileslice_trajectory():
traj = joutslice.trajectory
assert isinstance(traj, Trajectory)
del joutslice.jsettings_lattice.params["niterations"]
# joutslice.jsettings_lattice.params["niterations"] = None
with pytest.raises(ValueError, match=re.escape("Unknown issue due to partial initialization of settings objects.")):
traj = joutslice.trajectory

Expand All @@ -54,8 +53,6 @@ def test_get_broadeningvars():

def test_get_truncationvars():
joutslice = JDFTXOutfileSlice.from_out_slice(ex_slice1)
# with pytest.raises(ValueError, match="No truncation type found in out file."):
# joutslice.get_truncationvars([])
joutslice.is_bgw = True
with pytest.raises(ValueError, match="BGW slab Coulomb truncation must be along z!"):
joutslice.get_truncationvars(["coulomb-interaction Slab 010"])
Expand Down Expand Up @@ -94,17 +91,13 @@ def test_get_eigstats_varsdict():

def test_get_pp_type():
joutslice = JDFTXOutfileSlice.from_out_slice(ex_slice1)
# with pytest.raises(ValueError, match="Could not determine pseudopotential type from file name root/PAW"):
# joutslice.get_pp_type(["Reading pseudopotential file root/PAW:"])
assert joutslice.get_pp_type(["Reading pseudopotential file root/PAW:"]) is None
assert joutslice.get_pp_type(["Reading pseudopotential file not_SG15/GBRV"]) == "GBRV"
assert joutslice.get_pp_type(["Reading pseudopotential file not_GBRV/SG15"]) == "SG15"


def test_set_pseudo_vars_t1():
joutslice = JDFTXOutfileSlice.from_out_slice(ex_slice1)
str(joutslice)
repr(joutslice)
# Just need more bound sets than there are atom types
text = [
"Reading pseudopotential file not_SG15/GBRV",
Expand Down
71 changes: 0 additions & 71 deletions tests/io/jdftx/test_jdftxoutput.py

This file was deleted.

3 changes: 0 additions & 3 deletions tests/io/jdftx/test_jeiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ def test_JElSteps_known(
etype: str = "F",
eitertype="ElecMinimize",
):
# text_slice = []
# for exl in ex_lines:
# text_slice += exl
text_slice = [line for exl in ex_lines for line in exl]
jeis = JElSteps.from_text_slice(text_slice, opt_type=eitertype, etype=etype)
for var in [
Expand Down
34 changes: 0 additions & 34 deletions tests/io/jdftx/test_joutstructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,37 +91,3 @@ def test_jstructures(ex_slice: list[str], ex_slice_known: dict[str, float], opt_
assert jstruct.elecmindata.converged == ex_slice_known["conv-1"]
assert len(jstruct) == ex_slice_known["nGeomSteps"]
assert jstruct.selective_dynamics is not None


# @pytest.mark.parametrize(
# ("out_slice", "varname"),
# [
# (ex_outslice1, "etype"),
# (ex_outslice1, "eopt_type"),
# (ex_outslice1, "emin_flag"),
# (ex_outslice1, "ecomponents"),
# (ex_outslice1, "elecmindata"),
# (ex_outslice1, "stress"),
# (ex_outslice1, "strain"),
# (ex_outslice1, "nstep"),
# (ex_outslice1, "e"),
# (ex_outslice1, "grad_k"),
# (ex_outslice1, "alpha"),
# (ex_outslice1, "linmin"),
# (ex_outslice1, "nelectrons"),
# (ex_outslice1, "abs_magneticmoment"),
# (ex_outslice1, "tot_magneticmoment"),
# (ex_outslice1, "mu"),
# (ex_outslice1, "elec_nstep"),
# (ex_outslice1, "elec_e"),
# (ex_outslice1, "elec_grad_k"),
# (ex_outslice1, "elec_alpha"),
# (ex_outslice1, "elec_linmin"),
# ],
# )
# def test_joutstructures_has_1layer_slice_freakout(out_slice: list[str], varname: str):
# jstrucs = JOutStructures.from_out_slice(out_slice)
# getattr(jstrucs, varname) # No freakout here
# jstrucs.slices = []
# with pytest.raises(AttributeError):
# getattr(jstrucs, varname) # Freakout here
13 changes: 1 addition & 12 deletions tests/io/jdftx/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@
import pytest

from pymatgen.io.jdftx.joutstructures import get_joutstructures_start_idx

# from pymatgen.io.jdftx.generic_tags import flatten_list
# from pymatgen.io.jdftx.jdftxoutfileslice_helpers import find_first_range_key, get_start_lines
# from pymatgen.io.jdftx.joutstructure_helpers import get_joutstructures_start_idx
from pymatgen.io.jdftx.utils import (
find_first_range_key,
flatten_list,
# get_joutstructures_start_idx,
get_start_lines,
multi_getattr,
multi_hasattr,
)
from pymatgen.io.jdftx.utils import find_first_range_key, flatten_list, get_start_lines, multi_getattr, multi_hasattr


def test_flatten_list():
Expand Down

0 comments on commit 82fd73f

Please sign in to comment.