From 9ae0debc0fa1604b138e5a42292b4fa57102f6eb Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Wed, 4 Dec 2024 23:31:57 +0800 Subject: [PATCH] global replace get_structure --- tests/alchemy/test_materials.py | 4 ++-- tests/alchemy/test_transmuters.py | 2 +- .../structure_prediction/test_substitutor.py | 4 ++-- .../test_volume_predictor.py | 24 +++++++++---------- tests/core/test_structure.py | 8 +++---- tests/io/test_phonopy.py | 4 ++-- tests/io/vasp/test_sets.py | 8 +++---- tests/symmetry/test_analyzer.py | 8 +++---- .../test_advanced_transformations.py | 6 ++--- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/alchemy/test_materials.py b/tests/alchemy/test_materials.py index 10115842f8f..cd5d19b6d24 100644 --- a/tests/alchemy/test_materials.py +++ b/tests/alchemy/test_materials.py @@ -16,14 +16,14 @@ SupercellTransformation, ) from pymatgen.util.provenance import StructureNL -from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, MatSciTest TEST_DIR = f"{TEST_FILES_DIR}/alchemy" class TestTransformedStructure(MatSciTest): def setup_method(self): - structure = PymatgenTest.get_structure("LiFePO4") + structure = MatSciTest.get_structure("LiFePO4") self.structure = structure trafos = [SubstitutionTransformation({"Li": "Na"})] self.trans = TransformedStructure(structure, trafos) diff --git a/tests/alchemy/test_transmuters.py b/tests/alchemy/test_transmuters.py index fa249c2d500..e5697a459f0 100644 --- a/tests/alchemy/test_transmuters.py +++ b/tests/alchemy/test_transmuters.py @@ -8,7 +8,7 @@ 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, MatSciTest class TestCifTransmuter(MatSciTest): diff --git a/tests/analysis/structure_prediction/test_substitutor.py b/tests/analysis/structure_prediction/test_substitutor.py index a8626b5bf33..84ad08f4b6a 100644 --- a/tests/analysis/structure_prediction/test_substitutor.py +++ b/tests/analysis/structure_prediction/test_substitutor.py @@ -4,7 +4,7 @@ from pymatgen.analysis.structure_prediction.substitutor import Substitutor from pymatgen.core import Composition, Species -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, MatSciTest TEST_DIR = f"{TEST_FILES_DIR}/analysis/struct_predictor" @@ -32,7 +32,7 @@ def test_substitutor(self): subs = self.substitutor.pred_from_comp(comp) assert len(subs) == 4, "incorrect number of substitutions" - structures = [{"structure": PymatgenTest.get_structure("Li2O"), "id": "pmgtest"}] + structures = [{"structure": MatSciTest.get_structure("Li2O"), "id": "pmgtest"}] subs = self.substitutor.pred_from_structures(["Na+", "O2-"], structures) assert subs[0].formula == "Na2 O1" diff --git a/tests/analysis/structure_prediction/test_volume_predictor.py b/tests/analysis/structure_prediction/test_volume_predictor.py index b94bf999a50..da96904a990 100644 --- a/tests/analysis/structure_prediction/test_volume_predictor.py +++ b/tests/analysis/structure_prediction/test_volume_predictor.py @@ -5,38 +5,38 @@ from pymatgen.analysis.structure_prediction.volume_predictor import DLSVolumePredictor, RLSVolumePredictor from pymatgen.core import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, MatSciTest TEST_DIR = f"{TEST_FILES_DIR}/analysis/structure_prediction" class TestRLSVolumePredictor(MatSciTest): def test_predict(self): - struct = PymatgenTest.get_structure("CsCl") - nacl = PymatgenTest.get_structure("CsCl") + struct = MatSciTest.get_structure("CsCl") + nacl = MatSciTest.get_structure("CsCl") nacl.replace_species({"Cs": "Na"}) nacl.scale_lattice(184.384551033) predictor = RLSVolumePredictor(radii_type="ionic") assert predictor.predict(struct, nacl) == approx(342.84905395082535) predictor = RLSVolumePredictor(radii_type="atomic") assert predictor.predict(struct, nacl) == approx(391.884366481) - lif = PymatgenTest.get_structure("CsCl") + lif = MatSciTest.get_structure("CsCl") lif.replace_species({"Cs": "Li", "Cl": "F"}) predictor = RLSVolumePredictor(radii_type="ionic") assert predictor.predict(lif, nacl) == approx(74.268402413690467) predictor = RLSVolumePredictor(radii_type="atomic") assert predictor.predict(lif, nacl) == approx(62.2808125839) - lfpo = PymatgenTest.get_structure("LiFePO4") - lmpo = PymatgenTest.get_structure("LiFePO4") + lfpo = MatSciTest.get_structure("LiFePO4") + lmpo = MatSciTest.get_structure("LiFePO4") lmpo.replace_species({"Fe": "Mn"}) predictor = RLSVolumePredictor(radii_type="ionic") assert predictor.predict(lmpo, lfpo) == approx(310.08253254420134) predictor = RLSVolumePredictor(radii_type="atomic") assert predictor.predict(lmpo, lfpo) == approx(299.607967711) - sto = PymatgenTest.get_structure("SrTiO3") - scoo = PymatgenTest.get_structure("SrTiO3") + sto = MatSciTest.get_structure("SrTiO3") + scoo = MatSciTest.get_structure("SrTiO3") scoo.replace_species({"Ti4+": "Co4+"}) predictor = RLSVolumePredictor(radii_type="ionic") assert predictor.predict(scoo, sto) == approx(56.162534974936463) @@ -61,8 +61,8 @@ def test_predict(self): assert predictor.predict(apo, aps) == approx(1196.31384276) def test_modes(self): - cs_cl = PymatgenTest.get_structure("CsCl") - na_cl = PymatgenTest.get_structure("CsCl") + cs_cl = MatSciTest.get_structure("CsCl") + na_cl = MatSciTest.get_structure("CsCl") na_cl.replace_species({"Cs": "Na"}) na_cl.scale_lattice(184.384551033) vol_pred = RLSVolumePredictor(radii_type="ionic", use_bv=False) @@ -94,7 +94,7 @@ def test_predict(self): assert vol_pred.predict(fen) == approx(fen.volume * 1.5) assert p_fast.predict(fen) == approx(fen.volume * 1.5) - lfpo = PymatgenTest.get_structure("LiFePO4") + lfpo = MatSciTest.get_structure("LiFePO4") lfpo.scale_lattice(lfpo.volume * 3.0) assert p_nolimit.predict(lfpo) == approx(291.62094410192924) @@ -104,6 +104,6 @@ def test_predict(self): assert vol_pred.predict(lfpo) == approx(lfpo.volume * 1.5) assert p_fast.predict(lfpo) == approx(lfpo.volume * 1.5) - lmpo = PymatgenTest.get_structure("LiFePO4") + lmpo = MatSciTest.get_structure("LiFePO4") lmpo.replace_species({"Fe": "Mn"}) assert vol_pred.predict(lmpo) == approx(290.795329052) diff --git a/tests/core/test_structure.py b/tests/core/test_structure.py index 028cc36b234..24599a1c45b 100644 --- a/tests/core/test_structure.py +++ b/tests/core/test_structure.py @@ -30,7 +30,7 @@ from pymatgen.io.ase import AseAtomsAdaptor from pymatgen.io.cif import CifParser from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, MatSciTest try: from ase.atoms import Atoms @@ -46,7 +46,7 @@ class TestNeighbor(MatSciTest): def test_msonable(self): - struct = PymatgenTest.get_structure("Li2O") + struct = MatSciTest.get_structure("Li2O") nn = struct.get_neighbors(struct[0], r=3) assert isinstance(nn[0], PeriodicNeighbor) str_ = json.dumps(nn, cls=MontyEncoder) @@ -1024,7 +1024,7 @@ def test_mutable_sequence_methods(self): assert struct.formula == "Mn1" # Test slice replacement. - struct = PymatgenTest.get_structure("Li2O") + struct = MatSciTest.get_structure("Li2O") struct[:2] = "S" assert struct.formula == "Li1 S2" @@ -1267,7 +1267,7 @@ def test_remove_oxidation_states(self): assert struct_elem == struct_specie, "Oxidation state remover failed" def test_add_oxidation_state_by_guess(self): - struct = PymatgenTest.get_structure("Li2O") + struct = MatSciTest.get_structure("Li2O") returned = struct.add_oxidation_state_by_guess() assert returned is struct expected = [Species("Li", 1), Species("O", -2)] diff --git a/tests/io/test_phonopy.py b/tests/io/test_phonopy.py index e84414e72d7..d5e87392d69 100644 --- a/tests/io/test_phonopy.py +++ b/tests/io/test_phonopy.py @@ -28,7 +28,7 @@ get_pmg_structure, get_thermal_displacement_matrices, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, MatSciTest try: from phonopy import Phonopy @@ -99,7 +99,7 @@ def test_get_complete_dos(self): @pytest.mark.skipif(Phonopy is None, reason="Phonopy not present") class TestStructureConversion(MatSciTest): def test_structure_conversion(self): - struct_pmg = PymatgenTest.get_structure("LiFePO4") + struct_pmg = MatSciTest.get_structure("LiFePO4") # add magmoms to site_properties struct_pmg.add_site_property("magmom", magmoms := [1] * len(struct_pmg)) struct_ph = get_phonopy_structure(struct_pmg) diff --git a/tests/io/vasp/test_sets.py b/tests/io/vasp/test_sets.py index ec4a88bd0fc..db021659d33 100644 --- a/tests/io/vasp/test_sets.py +++ b/tests/io/vasp/test_sets.py @@ -54,7 +54,7 @@ get_valid_magmom_struct, ) from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, MatSciTest TEST_DIR = f"{TEST_FILES_DIR}/io/vasp" @@ -1501,7 +1501,7 @@ def test_incar(self): class TestMVLGWSet(MatSciTest): def setup_method(self): self.set = MVLGWSet - self.struct = PymatgenTest.get_structure("Li2O") + self.struct = MatSciTest.get_structure("Li2O") def test_static(self): assert self.set.mode == "STATIC" @@ -1675,7 +1675,7 @@ def test_init(self): assert vis.reciprocal_density == 100 with pytest.warns(BadInputSetWarning, match=r"Hybrid functionals"): - vis = self.set(PymatgenTest.get_structure("Li2O"), user_incar_settings={"ALGO": "Fast"}) + vis = self.set(MatSciTest.get_structure("Li2O"), user_incar_settings={"ALGO": "Fast"}) vis.incar.items() def test_override_from_prev_calc(self): @@ -1991,7 +1991,7 @@ def test_override_from_prev_calc(self): class TestFunc(MatSciTest): @skip_if_no_psp_dir def test_batch_write_input(self): - structs = list(map(PymatgenTest.get_structure, ("Li2O", "LiFePO4"))) + structs = list(map(MatSciTest.get_structure, ("Li2O", "LiFePO4"))) batch_write_input(structs, sanitize=True) for formula in ("Li4Fe4P4O16_1", "Li2O1_0"): diff --git a/tests/symmetry/test_analyzer.py b/tests/symmetry/test_analyzer.py index f67c9576b8c..baec09b105d 100644 --- a/tests/symmetry/test_analyzer.py +++ b/tests/symmetry/test_analyzer.py @@ -18,7 +18,7 @@ iterative_symmetrize, ) from pymatgen.symmetry.structure import SymmetrizedStructure -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, MatSciTest TEST_DIR = f"{TEST_FILES_DIR}/symmetry/analyzer" @@ -54,7 +54,7 @@ def test_is_laue(self): assert self.disordered_sg.is_laue() def test_magnetic(self): - lfp = PymatgenTest.get_structure("LiFePO4") + lfp = MatSciTest.get_structure("LiFePO4") sg = SpacegroupAnalyzer(lfp, 0.1) assert sg.get_space_group_symbol() == "Pnma" magmoms = [0] * len(lfp) @@ -670,7 +670,7 @@ def test_symmetrize_molecule2(self): def test_get_kpoint_weights(self): for name in ("SrTiO3", "LiFePO4", "Graphite"): - struct = PymatgenTest.get_structure(name) + struct = MatSciTest.get_structure(name) spga = SpacegroupAnalyzer(struct) ir_mesh = spga.get_ir_reciprocal_mesh((4, 4, 4)) weights = [i[1] for i in ir_mesh] @@ -679,7 +679,7 @@ def test_get_kpoint_weights(self): assert weight == approx(expected) for name in ("SrTiO3", "LiFePO4", "Graphite"): - struct = PymatgenTest.get_structure(name) + struct = MatSciTest.get_structure(name) spga = SpacegroupAnalyzer(struct) ir_mesh = spga.get_ir_reciprocal_mesh((1, 2, 3)) weights = [i[1] for i in ir_mesh] diff --git a/tests/transformations/test_advanced_transformations.py b/tests/transformations/test_advanced_transformations.py index 3e508b89867..7ba24428559 100644 --- a/tests/transformations/test_advanced_transformations.py +++ b/tests/transformations/test_advanced_transformations.py @@ -40,7 +40,7 @@ OxidationStateDecorationTransformation, SubstitutionTransformation, ) -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, MatSciTest try: import hiphive @@ -490,7 +490,7 @@ def test_advanced_usage(self): @pytest.mark.skipif(not enumlib_present, reason="enum_lib not present.") class TestDopingTransformation(MatSciTest): def test_apply_transformation(self): - structure = PymatgenTest.get_structure("LiFePO4") + structure = MatSciTest.get_structure("LiFePO4") spga = SpacegroupAnalyzer(structure, 0.1) structure = spga.get_refined_structure() trafo = DopingTransformation("Ca2+", min_length=10) @@ -524,7 +524,7 @@ def test_apply_transformation(self): assert d["structure"].charge == 0 # Make sure compensation is done with lowest oxi state - structure = PymatgenTest.get_structure("SrTiO3") + structure = MatSciTest.get_structure("SrTiO3") trafo = DopingTransformation( "Nb5+", min_length=5,