Skip to content

Commit

Permalink
batch remove PymatgenTest inheritance and see what fail
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Dec 3, 2024
1 parent 8bacdbc commit 344a872
Show file tree
Hide file tree
Showing 134 changed files with 387 additions and 423 deletions.
6 changes: 3 additions & 3 deletions tests/alchemy/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from pymatgen.alchemy.transmuters import StandardTransmuter
from pymatgen.analysis.structure_matcher import StructureMatcher
from pymatgen.core import Lattice, Species, Structure
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR


class TestContainsSpecieFilter(PymatgenTest):
class TestContainsSpecieFilter:
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 @@ -52,7 +52,7 @@ def test_as_from_dict(self):
assert isinstance(ContainsSpecieFilter.from_dict(dct), ContainsSpecieFilter)


class TestSpecieProximityFilter(PymatgenTest):
class TestSpecieProximityFilter:
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:
def setUp(self):
structure = PymatgenTest.get_structure("LiFePO4")
self.structure = structure
Expand Down
6 changes: 3 additions & 3 deletions tests/alchemy/test_transmuters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
RemoveSpeciesTransformation,
SubstitutionTransformation,
)
from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR


class TestCifTransmuter(PymatgenTest):
class TestCifTransmuter:
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:
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 @@ -20,12 +20,12 @@
from pymatgen.core.lattice import Lattice
from pymatgen.core.sites import PeriodicSite
from pymatgen.core.structure import Structure
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"


class TestConnectedComponent(PymatgenTest):
class TestConnectedComponent:
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 @@ -3,7 +3,6 @@
import json

from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode
from pymatgen.util.testing import PymatgenTest

try:
import bson
Expand All @@ -13,7 +12,7 @@
__author__ = "waroquiers"


class TestEnvironmentNodes(PymatgenTest):
class TestEnvironmentNodes:
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 @@ -9,12 +9,12 @@
LightStructureEnvironments,
StructureEnvironments,
)
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"


class TestStructureConnectivity(PymatgenTest):
class TestStructureConnectivity:
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 @@ -10,12 +10,11 @@
DistanceCutoffFloat,
SimplestChemenvStrategy,
)
from pymatgen.util.testing import PymatgenTest

__author__ = "waroquiers"


class TestStrategyOptions(PymatgenTest):
class TestStrategyOptions:
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 @@ -11,7 +11,6 @@
ExplicitPermutationsAlgorithm,
SeparationPlane,
)
from pymatgen.util.testing import PymatgenTest

__author__ = "waroquiers"

Expand All @@ -23,7 +22,7 @@ def __init__(self, coords):
self.coords = coords


class TestCoordinationGeometries(PymatgenTest):
class TestCoordinationGeometries:
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 @@ -19,14 +19,14 @@
symmetry_measure,
)
from pymatgen.core.structure import Lattice, Structure
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"

json_dir = f"{TEST_FILES_DIR}/analysis/chemenv/json"


class TestCoordinationGeometryFinder(PymatgenTest):
class TestCoordinationGeometryFinder:
def setUp(self):
self.lgf = LocalGeometryFinder()
self.lgf.setup_parameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
)
from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer
from pymatgen.core.structure import Structure
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"

json_dir = f"{TEST_FILES_DIR}/analysis/chemenv/json"
struct_env_dir = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments"


class TestReadWriteChemenv(PymatgenTest):
class TestReadWriteChemenv:
@classmethod
def setUpClass(cls):
cls.lgf = LocalGeometryFinder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
StructureEnvironments,
)
from pymatgen.core import Species, Structure
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"

TEST_DIR = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments"


class TestStructureEnvironments(PymatgenTest):
class TestStructureEnvironments:
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 @@ -5,14 +5,14 @@
from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"

img_files_dir = f"{TEST_FILES_DIR}/analysis/chemenv/images"


class TestVoronoiContainer(PymatgenTest):
class TestVoronoiContainer:
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 @@ -16,7 +16,7 @@
SelfCSMNbSetWeight,
)
from pymatgen.analysis.chemenv.coordination_environments.structure_environments import StructureEnvironments
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"

Expand All @@ -39,7 +39,7 @@ class DummyVoronoiContainer:
pass


class StrategyWeights(PymatgenTest):
class StrategyWeights:
def test_angle_weight(self):
fake_nb_set = FakeNbSet()
dummy_se = DummyStructureEnvironments()
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/chemenv/utils/test_chemenv_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from pymatgen.analysis.chemenv.utils.chemenv_config import ChemEnvConfig
from pymatgen.core import SETTINGS
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

__author__ = "waroquiers"

config_file_dir = f"{TEST_FILES_DIR}/analysis/chemenv/config"


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
from pytest import approx

from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import Plane
from pymatgen.util.testing import PymatgenTest

__author__ = "David Waroquiers"


class TestPlanesUtils(PymatgenTest):
class TestPlanesUtils:
def setUp(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
5 changes: 2 additions & 3 deletions tests/analysis/chemenv/utils/test_graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode
from pymatgen.analysis.chemenv.utils.graph_utils import MultiGraphCycle, SimpleGraphCycle, get_delta
from pymatgen.util.testing import PymatgenTest

__author__ = "waroquiers"

Expand Down Expand Up @@ -68,7 +67,7 @@ def __lt__(self, other):
return self.isite % 2 < other.isite % 2


class TestGraphUtils(PymatgenTest):
class TestGraphUtils:
def test_get_delta(self):
n1 = FakeNode(3)
n2 = FakeNode(7)
Expand Down Expand Up @@ -664,7 +663,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:
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
3 changes: 1 addition & 2 deletions tests/analysis/chemenv/utils/test_math_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
smootherstep,
smoothstep,
)
from pymatgen.util.testing import PymatgenTest

__author__ = "waroquiers"


class TestMathUtils(PymatgenTest):
class TestMathUtils:
def test_list_cartesian_product(self):
list_of_lists = [[0, 1], [2, 5, 4], [5]]
assert _cartesian_product(lists=list_of_lists) == [
Expand Down
3 changes: 1 addition & 2 deletions tests/analysis/diffraction/test_neutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pymatgen.analysis.diffraction.neutron import NDCalculator
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.util.testing import PymatgenTest

"""
These calculated values were verified with VESTA and FullProf.
Expand All @@ -20,7 +19,7 @@
__date__ = "4/19/18"


class TestNDCalculator(PymatgenTest):
class TestNDCalculator:
def test_get_pattern(self):
struct = self.get_structure("CsCl")
c = NDCalculator(wavelength=1.54184) # CuKa radiation
Expand Down
3 changes: 1 addition & 2 deletions tests/analysis/diffraction/test_tem.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pymatgen.analysis.diffraction.tem import TEMCalculator
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.util.testing import PymatgenTest

__author__ = "Frank Wan, Jason Liang"
__copyright__ = "Copyright 2019, The Materials Project"
Expand All @@ -21,7 +20,7 @@
__date__ = "2/20/20"


class TestTEMCalculator(PymatgenTest):
class TestTEMCalculator:
def test_wavelength_rel(self):
# Test that the relativistic wavelength formula (for 200 kV electron beam) is correct
tem_calc = TEMCalculator()
Expand Down
3 changes: 1 addition & 2 deletions tests/analysis/diffraction/test_xrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pymatgen.analysis.diffraction.xrd import XRDCalculator
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.util.testing import PymatgenTest

__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2012, The Materials Project"
Expand All @@ -16,7 +15,7 @@
__date__ = "5/22/14"


class TestXRDCalculator(PymatgenTest):
class TestXRDCalculator:
def test_type_wavelength(self):
"""Test TypeError is raised if wavelength is unaccepted type."""
wavelength = [1.78, 2.78] # just a list
Expand Down
10 changes: 5 additions & 5 deletions tests/analysis/elasticity/test_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
from pymatgen.core.structure import Structure
from pymatgen.core.tensors import Tensor
from pymatgen.core.units import FloatWithUnit
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR

TEST_DIR = f"{TEST_FILES_DIR}/analysis/elasticity"


class TestElasticTensor(PymatgenTest):
class TestElasticTensor:
def setUp(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:
def setUp(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:
def setUp(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:
"""Test various functions related to diff fitting."""

def setUp(self):
Expand Down
Loading

0 comments on commit 344a872

Please sign in to comment.