Skip to content

Commit

Permalink
global replace inheritance from PymatgenTest
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Dec 4, 2024
1 parent 4429546 commit 98f7fc7
Show file tree
Hide file tree
Showing 134 changed files with 295 additions and 295 deletions.
4 changes: 2 additions & 2 deletions tests/alchemy/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest


class TestContainsSpecieFilter(PymatgenTest):
class TestContainsSpecieFilter(MatSciTest):
def test_filtering(self):
coords = [[0, 0, 0], [0.75, 0.75, 0.75], [0.5, 0.5, 0.5], [0.25, 0.25, 0.25]]
lattice = Lattice([[3.0, 0.0, 0.0], [1.0, 3.0, 0], [0, -2.0, 3.0]])
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_as_from_dict(self):
assert isinstance(ContainsSpecieFilter.from_dict(dct), ContainsSpecieFilter)


class TestSpecieProximityFilter(PymatgenTest):
class TestSpecieProximityFilter(MatSciTest):
def test_filter(self):
struct = self.get_structure("Li10GeP2S12")
sf = SpecieProximityFilter({"Li": 1})
Expand Down
2 changes: 1 addition & 1 deletion tests/alchemy/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
TEST_DIR = f"{TEST_FILES_DIR}/alchemy"


class TestTransformedStructure(PymatgenTest):
class TestTransformedStructure(MatSciTest):
def setup_method(self):
structure = PymatgenTest.get_structure("LiFePO4")
self.structure = structure
Expand Down
4 changes: 2 additions & 2 deletions tests/alchemy/test_transmuters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest


class TestCifTransmuter(PymatgenTest):
class TestCifTransmuter(MatSciTest):
def test_init(self):
trafos = [SubstitutionTransformation({"Fe": "Mn", "Fe2+": "Mn2+"})]
tsc = CifTransmuter.from_filenames([f"{TEST_FILES_DIR}/cif/MultiStructure.cif"], trafos)
Expand All @@ -22,7 +22,7 @@ def test_init(self):
assert expected == els


class TestPoscarTransmuter(PymatgenTest):
class TestPoscarTransmuter(MatSciTest):
def test_init(self):
trafos = [SubstitutionTransformation({"Fe": "Mn"})]
tsc = PoscarTransmuter.from_filenames([f"{VASP_IN_DIR}/POSCAR", f"{VASP_IN_DIR}/POSCAR"], trafos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
__author__ = "waroquiers"


class TestConnectedComponent(PymatgenTest):
class TestConnectedComponent(MatSciTest):
def test_init(self):
# Generic connected component not using EnvironmentNodes
# (as_dict won't work on such a ConnectedComponent instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__author__ = "waroquiers"


class TestEnvironmentNodes(PymatgenTest):
class TestEnvironmentNodes(MatSciTest):
def test_equal(self):
struct = self.get_structure("SiO2")
en = EnvironmentNode(central_site=struct[0], i_central_site=0, ce_symbol="T:4")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
__author__ = "waroquiers"


class TestStructureConnectivity(PymatgenTest):
class TestStructureConnectivity(MatSciTest):
def test_serialization(self):
BaTiO3_se_fpath = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments/se_mp-5020.json"
with open(BaTiO3_se_fpath) as file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__author__ = "waroquiers"


class TestStrategyOptions(PymatgenTest):
class TestStrategyOptions(MatSciTest):
def test_options(self):
# DistanceCutoffFloat
with pytest.raises(ValueError, match=r"Distance cutoff should be between 1 and \+infinity"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, coords):
self.coords = coords


class TestCoordinationGeometries(PymatgenTest):
class TestCoordinationGeometries(MatSciTest):
def test_algorithms(self):
expl_algo = ExplicitPermutationsAlgorithm(permutations=[[0, 1, 2], [1, 2, 3]])
expl_algo2 = ExplicitPermutationsAlgorithm.from_dict(expl_algo.as_dict())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
json_dir = f"{TEST_FILES_DIR}/analysis/chemenv/json"


class TestCoordinationGeometryFinder(PymatgenTest):
class TestCoordinationGeometryFinder(MatSciTest):
def setup_method(self):
self.lgf = LocalGeometryFinder()
self.lgf.setup_parameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
struct_env_dir = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments"


class TestReadWriteChemenv(PymatgenTest):
class TestReadWriteChemenv(MatSciTest):
@classmethod
def setup_class(cls):
cls.lgf = LocalGeometryFinder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
TEST_DIR = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments"


class TestStructureEnvironments(PymatgenTest):
class TestStructureEnvironments(MatSciTest):
def test_structure_environments(self):
with open(f"{TEST_DIR}/se_mp-7000.json") as file:
dct = json.load(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
img_files_dir = f"{TEST_FILES_DIR}/analysis/chemenv/images"


class TestVoronoiContainer(PymatgenTest):
class TestVoronoiContainer(MatSciTest):
def test_voronoi(self):
# Define a cubic lattice and a list of species (to be used for the fake structures)
cubic_lattice = Lattice.cubic(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DummyVoronoiContainer:
pass


class StrategyWeights(PymatgenTest):
class StrategyWeights(MatSciTest):
def test_angle_weight(self):
fake_nb_set = FakeNbSet()
dummy_se = DummyStructureEnvironments()
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/chemenv/utils/test_chemenv_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
config_file_dir = f"{TEST_FILES_DIR}/analysis/chemenv/config"


class TestChemenvConfig(PymatgenTest):
class TestChemenvConfig(MatSciTest):
def test_chemenv_config(self):
config = ChemEnvConfig()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__author__ = "David Waroquiers"


class TestPlanesUtils(PymatgenTest):
class TestPlanesUtils(MatSciTest):
def setup_method(self):
# Test of plane 4x + 2y - 4z + 3 = 0 (used in most test cases)
self.expected_coefficients = np.array([4, 2, -4, 3], float)
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/chemenv/utils/test_graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __lt__(self, other):
return self.isite % 2 < other.isite % 2


class TestGraphUtils(PymatgenTest):
class TestGraphUtils(MatSciTest):
def test_get_delta(self):
n1 = FakeNode(3)
n2 = FakeNode(7)
Expand Down Expand Up @@ -664,7 +664,7 @@ def test_multigraph_cycle(self):
assert mgc.edge_indices == edges_ref, f"Edges not equal for inodes = ({str_nodes})"


class TestEnvironmentNodesGraphUtils(PymatgenTest):
class TestEnvironmentNodesGraphUtils(MatSciTest):
def test_cycle(self):
e1 = EnvironmentNode(central_site="Si", i_central_site=0, ce_symbol="T:4")
e2 = EnvironmentNode(central_site="Si", i_central_site=3, ce_symbol="T:4")
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/chemenv/utils/test_math_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
__author__ = "waroquiers"


class TestMathUtils(PymatgenTest):
class TestMathUtils(MatSciTest):
def test_list_cartesian_product(self):
list_of_lists = [[0, 1], [2, 5, 4], [5]]
assert _cartesian_product(lists=list_of_lists) == [
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/diffraction/test_neutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
__date__ = "4/19/18"


class TestNDCalculator(PymatgenTest):
class TestNDCalculator(MatSciTest):
def test_get_pattern(self):
struct = self.get_structure("CsCl")
c = NDCalculator(wavelength=1.54184) # CuKa radiation
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/diffraction/test_tem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
__date__ = "2/20/20"


class TestTEMCalculator(PymatgenTest):
class TestTEMCalculator(MatSciTest):
def test_wavelength_rel(self):
# Test that the relativistic wavelength formula (for 200 kV electron beam) is correct
tem_calc = TEMCalculator()
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/diffraction/test_xrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
__date__ = "5/22/14"


class TestXRDCalculator(PymatgenTest):
class TestXRDCalculator(MatSciTest):
def test_type_wavelength(self):
"""Test TypeError is raised if wavelength is unaccepted type."""
wavelength = [1.78, 2.78] # just a list
Expand Down
8 changes: 4 additions & 4 deletions tests/analysis/elasticity/test_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
TEST_DIR = f"{TEST_FILES_DIR}/analysis/elasticity"


class TestElasticTensor(PymatgenTest):
class TestElasticTensor(MatSciTest):
def setup_method(self):
self.voigt_1 = [
[59.33, 28.08, 28.08, 0, 0, 0],
Expand Down Expand Up @@ -263,7 +263,7 @@ def test_energy_density(self):
)


class TestElasticTensorExpansion(PymatgenTest):
class TestElasticTensorExpansion(MatSciTest):
def setup_method(self):
with open(f"{TEST_DIR}/test_toec_data.json") as file:
self.data_dict = json.load(file)
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_get_yield_stress(self):
self.exp_cu_4.get_yield_stress([1, 0, 0])


class TestNthOrderElasticTensor(PymatgenTest):
class TestNthOrderElasticTensor(MatSciTest):
def setup_method(self):
with open(f"{TEST_DIR}/test_toec_data.json") as file:
self.data_dict = json.load(file)
Expand Down Expand Up @@ -401,7 +401,7 @@ def test_energy_density(self):
self.c3.energy_density(self.strains[0])


class TestDiffFit(PymatgenTest):
class TestDiffFit(MatSciTest):
"""Test various functions related to diff fitting."""

def setup_method(self):
Expand Down
6 changes: 3 additions & 3 deletions tests/analysis/elasticity/test_strain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pymatgen.util.testing import PymatgenTest


class TestDeformation(PymatgenTest):
class TestDeformation(MatSciTest):
def setup_method(self):
self.norm_defo = Deformation.from_index_amount((0, 0), 0.02)
self.ind_defo = Deformation.from_index_amount((0, 1), 0.02)
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_apply_to_structure(self):
assert_allclose(new_coord, defo_coord)


class TestStrain(PymatgenTest):
class TestStrain(MatSciTest):
def setup_method(self):
self.norm_str = Strain.from_deformation([[1.02, 0, 0], [0, 1, 0], [0, 0, 1]])
self.ind_str = Strain.from_deformation([[1, 0.02, 0], [0, 1, 0], [0, 0, 1]])
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_convert_strain_to_deformation(self):
assert_allclose(defo.green_lagrange_strain, strain)


class TestDeformedStructureSet(PymatgenTest):
class TestDeformedStructureSet(MatSciTest):
def setup_method(self):
self.structure = self.get_structure("Sn")
self.default_dss = DeformedStructureSet(self.structure)
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/elasticity/test_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pymatgen.util.testing import PymatgenTest


class TestStress(PymatgenTest):
class TestStress(MatSciTest):
def setup_method(self):
self.rand_stress = Stress(np.random.default_rng().standard_normal((3, 3)))
self.symm_stress = Stress([[0.51, 2.29, 2.42], [2.29, 5.14, 5.07], [2.42, 5.07, 5.33]])
Expand Down
6 changes: 3 additions & 3 deletions tests/analysis/ferroelectricity/test_polarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
)


class TestUtils(PymatgenTest):
class TestUtils(MatSciTest):
def setup_method(self):
self.potcar = Potcar.from_file(f"{TEST_DIR}/POTCAR")
self.zval_dict = {"Ba": 10, "Ti": 10, "O": 6}
Expand All @@ -54,7 +54,7 @@ def test_get_total_ionic_dipole(self):
assert_allclose(p_ion, self.ions[-1].ravel().tolist())


class TestPolarization(PymatgenTest):
class TestPolarization(MatSciTest):
def setup_method(self):
self.p_ions = ions
self.p_ions_outcar = np.array(
Expand Down Expand Up @@ -258,7 +258,7 @@ def test_smoothness(self):
assert_allclose(self.smoothness_all_in_polar, smoothness)


class TestEnergyTrend(PymatgenTest):
class TestEnergyTrend(MatSciTest):
def setup_method(self):
self.energies = [
-7.97738049,
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/interfaces/test_coherent_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pymatgen.util.testing import PymatgenTest


class TestInterfaceBuilder(PymatgenTest):
class TestInterfaceBuilder(MatSciTest):
@classmethod
def setup_class(cls):
si_struct = cls.get_structure("Si")
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/interfaces/test_zsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
__date__ = "2/5/16"


class TestZSLGen(PymatgenTest):
class TestZSLGen(MatSciTest):
def setup_method(self):
# Film VO2
self.film = SpacegroupAnalyzer(self.get_structure("VO2"), symprec=0.1).get_conventional_standard_structure()
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/solar/test_slme.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
TEST_DIR = f"{TEST_FILES_DIR}/analysis/solar"


class TestSolar(PymatgenTest):
class TestSolar(MatSciTest):
def test_slme_from_vasprun(self):
en, abz, dir_gap, indir_gap = optics(f"{TEST_DIR}/vasprun.xml")
abz *= 100.0
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/structure_prediction/test_substitutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_table():
return json.load(file)


class TestSubstitutor(PymatgenTest):
class TestSubstitutor(MatSciTest):
def setup_method(self):
self.substitutor = Substitutor(threshold=1e-3, lambda_table=get_table(), alpha=-5.0)

Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/structure_prediction/test_volume_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
TEST_DIR = f"{TEST_FILES_DIR}/analysis/structure_prediction"


class TestRLSVolumePredictor(PymatgenTest):
class TestRLSVolumePredictor(MatSciTest):
def test_predict(self):
struct = PymatgenTest.get_structure("CsCl")
nacl = PymatgenTest.get_structure("CsCl")
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_modes(self):
assert vol_pred.predict(cs_cl, na_cl) == approx(342.84905395082535)


class TestDLSVolumePredictor(PymatgenTest):
class TestDLSVolumePredictor(MatSciTest):
def test_predict(self):
vol_pred = DLSVolumePredictor()
p_fast = DLSVolumePredictor(cutoff=0.0) # for speed on compressed cells
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/test_adsorption.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pymatgen.util.testing import PymatgenTest


class TestAdsorbateSiteFinder(PymatgenTest):
class TestAdsorbateSiteFinder(MatSciTest):
def setup_method(self):
self.structure = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3.5), ["Ni"], [[0, 0, 0]])
lattice = Lattice.cubic(3.010)
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/test_bond_valence.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
TEST_DIR = f"{TEST_FILES_DIR}/analysis/bond_valence"


class TestBVAnalyzer(PymatgenTest):
class TestBVAnalyzer(MatSciTest):
def setup_method(self):
self.analyzer = BVAnalyzer()

Expand Down Expand Up @@ -44,7 +44,7 @@ def test_get_oxi_state_structure(self):
assert Species("Mn4+") in oxi_struct.composition.elements


class TestBondValenceSum(PymatgenTest):
class TestBondValenceSum(MatSciTest):
def test_calculate_bv_sum(self):
struct = Structure.from_file(f"{TEST_DIR}/LiMn2O4.json")
neighbors = struct.get_neighbors(struct[0], 3.0)
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/test_chempot_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
TEST_DIR = f"{TEST_FILES_DIR}/analysis"


class TestChemicalPotentialDiagram(PymatgenTest):
class TestChemicalPotentialDiagram(MatSciTest):
def setup_method(self):
self.entries = EntrySet.from_csv(f"{TEST_DIR}/pd_entries_test.csv")
self.cpd_ternary, self.cpd_ternary_formal = (
Expand Down
Loading

0 comments on commit 98f7fc7

Please sign in to comment.