Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up test files: dedicated VASP directories, xyz, mcif, cssr, exciting, wannier90 #3681

Merged
merged 44 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6100231
relocate fixture dir: absorption
DanielYang59 Mar 9, 2024
87721c9
relocate dir: absorption
DanielYang59 Mar 9, 2024
7779c43
relocate `BTO_221_99_polarization` dir
DanielYang59 Mar 9, 2024
168a8bd
remove unused `chgden`
DanielYang59 Mar 9, 2024
f8c4de2
remove unused `defect`
DanielYang59 Mar 9, 2024
f213401
relocate `fe_monomer`
DanielYang59 Mar 9, 2024
64d04e5
relocate
DanielYang59 Mar 9, 2024
61d6cd3
relocate `fake_potcars`
DanielYang59 Mar 9, 2024
ab1ddb4
Reapply "relocate fake_potcars"
DanielYang59 Mar 9, 2024
de1bbeb
relocate `grid_data_files`
DanielYang59 Mar 9, 2024
2e676d7
relocate `kpoints_opt`
DanielYang59 Mar 9, 2024
c581294
relocate `neb_analysis`
DanielYang59 Mar 9, 2024
31534d2
fix path typo
DanielYang59 Mar 9, 2024
05fc896
remove unused `path_finder`
DanielYang59 Mar 9, 2024
e3dde14
relocate `relaxation`
DanielYang59 Mar 9, 2024
f804a7d
relocate `reproduce_eps`
DanielYang59 Mar 9, 2024
9cb91e4
fix same typo again
DanielYang59 Mar 9, 2024
1bdc0e2
fix neb file path
DanielYang59 Mar 9, 2024
d3a1a52
relocate `scan_relaxation`
DanielYang59 Mar 9, 2024
03b1405
relocate `static_silicon`
DanielYang59 Mar 9, 2024
46d1f51
remove unused `Zr_Vasprun`
DanielYang59 Mar 9, 2024
7f13e5d
relocate `thermal_displacement_matrices`
DanielYang59 Mar 9, 2024
139b0c6
remove unused `ion_placer` from qchem
DanielYang59 Mar 10, 2024
9bc08e5
relocate VASP output WSWQ
DanielYang59 Mar 10, 2024
9d1abc2
remove unused file `sio2.pw.in`
DanielYang59 Mar 10, 2024
a0bb1e9
relocate fiesta file
DanielYang59 Mar 10, 2024
02068e9
relocate some `xyz` files
DanielYang59 Mar 10, 2024
fb6f9fd
relocate `exciting` files
DanielYang59 Mar 10, 2024
d2be8f2
relocate cssr files
DanielYang59 Mar 10, 2024
b92ab99
relocate `wannier90`files
DanielYang59 Mar 10, 2024
4ab8ca3
relocate multiple mcif files
DanielYang59 Mar 10, 2024
05aaec9
try gzip vasprun.xml in vasp fixtures
DanielYang59 Mar 10, 2024
27a4eeb
try removing skip `matgl`
DanielYang59 Mar 10, 2024
74dc13b
Revert "try removing skip `matgl`"
DanielYang59 Mar 10, 2024
a88e3d4
decompress vasprun for optics
DanielYang59 Mar 10, 2024
b4afa7a
relocate a mcif file
DanielYang59 Mar 11, 2024
6f1c23a
relocate gulp and remove moved mcif
DanielYang59 Mar 11, 2024
d9798d5
create dir for `borg`
DanielYang59 Mar 11, 2024
5de2312
create dedicated `borg` test dir
DanielYang59 Mar 11, 2024
b1017cf
Merge branch 'master' into relocate-vasp-fixtures
DanielYang59 Mar 11, 2024
e7ae000
removed unnecessary self.
DanielYang59 Mar 11, 2024
f8cbd04
fix path and use stronger assert
DanielYang59 Mar 11, 2024
9a02dfe
revert vasprun to "vasp run"
DanielYang59 Mar 11, 2024
72d6fd2
add type hints
janosh Mar 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dev_scripts/potcar_scrambler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pymatgen.core import SETTINGS
from pymatgen.io.vasp import Potcar, PotcarSingle
from pymatgen.io.vasp.sets import _load_yaml_config
from pymatgen.util.testing import VASP_IN_DIR


class PotcarScrambler:
Expand Down Expand Up @@ -180,7 +181,7 @@ def potcar_cleanser():
and freely shared by VASP)
"""

search_dir = "../tests/files/fake_potcars/real_potcars/"
search_dir = f"{VASP_IN_DIR}/fake_potcars/real_potcars/"
rebase_dir = search_dir.replace("real", "fake")
potcars_to_cleanse = glob(f"{search_dir}/**/POTCAR*", recursive=True)

Expand Down
2 changes: 1 addition & 1 deletion pymatgen/apps/borg/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class VaspToComputedEntryDrone(AbstractDrone):

There are some restrictions on the valid directory structures:

1. There can be only one vasp run in each directory.
1. There can be only one vasprun in each directory.
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved
2. Directories designated "relax1", "relax2" are considered to be 2 parts
of an aflow style run, and only "relax2" is parsed.
3. The drone parses only the vasprun.xml file.
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/util/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# fake POTCARs have original header information, meaning properties like number of electrons,
# nuclear charge, core radii, etc. are unchanged (important for testing) while values of the and
# pseudopotential kinetic energy corrections are scrambled to avoid VASP copyright infringement
FAKE_POTCAR_DIR = TEST_FILES_DIR / "fake_potcars"
FAKE_POTCAR_DIR = f"{VASP_IN_DIR}/fake_potcars"


class PymatgenTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/ferroelectricity/test_polarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pymatgen.io.vasp.outputs import Outcar
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest

TEST_DIR = f"{TEST_FILES_DIR}/BTO_221_99_polarization"
TEST_DIR = f"{TEST_FILES_DIR}/vasp/fixtures/BTO_221_99_polarization"
bto_folders = ["nonpolar_polarization"]
bto_folders += [f"interpolation_{i}_polarization" for i in range(1, 9)][::-1]
bto_folders += ["polar_polarization"]
Expand Down
6 changes: 3 additions & 3 deletions tests/analysis/magnetism/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def setUp(self):

self.Fe3O4 = Structure.from_file(f"{TEST_FILES_DIR}/Fe3O4.cif", primitive=True)

self.GdB4 = Structure.from_file(f"{TEST_FILES_DIR}/magnetic.ncl.example.GdB4.mcif", primitive=True)
self.GdB4 = Structure.from_file(f"{TEST_FILES_DIR}/mcif/magnetic.ncl.example.GdB4.mcif", primitive=True)

self.NiO_expt = Structure.from_file(f"{TEST_FILES_DIR}/magnetic.example.NiO.mcif", primitive=True)
self.NiO_expt = Structure.from_file(f"{TEST_FILES_DIR}/mcif/magnetic.example.NiO.mcif", primitive=True)

# CuO.mcif sourced from https://www.cryst.ehu.es/magndata/index.php?index=1.62
# doi: 10.1088/0022-3719/21/15/023
self.CuO_expt = Structure.from_file(f"{TEST_FILES_DIR}/magnetic.example.CuO.mcif.gz", primitive=True)
self.CuO_expt = Structure.from_file(f"{TEST_FILES_DIR}/mcif/magnetic.example.CuO.mcif.gz", primitive=True)

lattice = Lattice.cubic(4.17)
species = ["Ni", "O"]
Expand Down
8 changes: 4 additions & 4 deletions tests/analysis/test_local_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ def test_get_nn(self):
class TestOpenBabelNN(PymatgenTest):
def setUp(self):
pytest.importorskip("openbabel")
self.benzene = Molecule.from_file(f"{TEST_FILES_DIR}/benzene.xyz")
self.acetylene = Molecule.from_file(f"{TEST_FILES_DIR}/acetylene.xyz")
self.benzene = Molecule.from_file(f"{TEST_FILES_DIR}/xyz/benzene.xyz")
self.acetylene = Molecule.from_file(f"{TEST_FILES_DIR}/xyz/acetylene.xyz")

def test_nn_orders(self):
strategy = OpenBabelNN()
Expand Down Expand Up @@ -318,8 +318,8 @@ def test_nn_length(self):

class TestCovalentBondNN(PymatgenTest):
def setUp(self):
self.benzene = Molecule.from_file(f"{TEST_FILES_DIR}/benzene.xyz")
self.acetylene = Molecule.from_file(f"{TEST_FILES_DIR}/acetylene.xyz")
self.benzene = Molecule.from_file(f"{TEST_FILES_DIR}/xyz/benzene.xyz")
self.acetylene = Molecule.from_file(f"{TEST_FILES_DIR}/xyz/acetylene.xyz")

def test_nn_orders(self):
strategy = CovalentBondNN()
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/test_transition_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
__date__ = "2/5/16"


TEST_DIR = f"{TEST_FILES_DIR}/neb_analysis"
TEST_DIR = f"{TEST_FILES_DIR}/vasp/fixtures/neb_analysis"


class TestNEBAnalysis(PymatgenTest):
Expand Down
35 changes: 15 additions & 20 deletions tests/apps/borg/test_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import unittest

from monty.tempfile import ScratchDir
from pytest import approx

from pymatgen.apps.borg.hive import (
Expand All @@ -26,25 +25,21 @@ def test_get_valid_paths(self):
assert len(self.drone.get_valid_paths(path)) > 0

def test_assimilate(self):
"""Test assimilate data from "vasprun.xe.xml.gz" file."""

with ScratchDir("."):
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved
# Need to rename the test file to "vasprun.xml.xe.gz" as
# hive is looking for pattern "vasprun.xml*"
os.symlink(f"{VASP_OUT_DIR}/vasprun.xe.xml.gz", "vasprun.xml.xe.gz")
entry = self.drone.assimilate(".")

for param in ("hubbards", "is_hubbard", "potcar_spec", "run_type"):
assert param in entry.parameters
assert entry.data["efermi"] == approx(-6.62148548)
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)

entry = self.structure_drone.assimilate(".")
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)
assert isinstance(entry, ComputedStructureEntry)
assert entry.structure is not None
"""Test assimilate data from "vasprun.xml.xe.gz" file."""

entry = self.drone.assimilate(f"{TEST_FILES_DIR}/app_borg/test_dir")

for param in ("hubbards", "is_hubbard", "potcar_spec", "run_type"):
assert param in entry.parameters
assert entry.data["efermi"] == approx(-6.62148548)
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)

entry = self.structure_drone.assimilate(f"{TEST_FILES_DIR}/app_borg/test_dir")
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)
assert isinstance(entry, ComputedStructureEntry)
assert entry.structure is not None

def test_as_from_dict(self):
dct = self.structure_drone.as_dict()
Expand Down
14 changes: 8 additions & 6 deletions tests/apps/borg/test_queen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""Created on Mar 18, 2012."""
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved

from __future__ import annotations

import unittest
Expand All @@ -12,16 +10,20 @@
__copyright__ = "Copyright 2012, The Materials Project"
__date__ = "Mar 18, 2012"

TEST_DIR = f"{TEST_FILES_DIR}/app_borg"


class TestBorgQueen(unittest.TestCase):
def test_get_data(self):
"""Test get data from vasprun.xml.xe.gz file."""
drone = VaspToComputedEntryDrone()
self.queen = BorgQueen(drone, TEST_FILES_DIR, 1)
data = self.queen.get_data()
assert len(data) == 16
queen = BorgQueen(drone, TEST_DIR, 1)
data = queen.get_data()
assert len(data) == 1
assert data[0].energy == 0.5559329
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved

def test_load_data(self):
drone = VaspToComputedEntryDrone()
queen = BorgQueen(drone)
queen.load_data(f"{TEST_FILES_DIR}/assimilated.json")
queen.load_data(f"{TEST_DIR}/assimilated.json")
assert len(queen.get_data()) == 1
2 changes: 1 addition & 1 deletion tests/command_line/test_gulp_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_get_energy(self):
def test_get_relaxed_structure(self):
# Output string obtained from running GULP on a terminal

with open(f"{TEST_FILES_DIR}/example21.gout") as file:
with open(f"{TEST_FILES_DIR}/gulp/example21.gout") as file:
out_str = file.read()
struct = self.gio.get_relaxed_structure(out_str)
assert isinstance(struct, Structure)
Expand Down
6 changes: 3 additions & 3 deletions tests/core/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,12 @@ def test_to_from_file_and_string(self):

# test CIF file with unicode error
# https://github.com/materialsproject/pymatgen/issues/2947
struct = Structure.from_file(f"{TEST_FILES_DIR}/bad-unicode-gh-2947.mcif")
struct = Structure.from_file(f"{TEST_FILES_DIR}/mcif/bad-unicode-gh-2947.mcif")
assert struct.formula == "Ni32 O32"

# make sure CIfParser.parse_structures() and Structure.from_file() are consistent
# i.e. uses same merge_tol for site merging, same primitive=False, etc.
assert struct == CifParser(f"{TEST_FILES_DIR}/bad-unicode-gh-2947.mcif").parse_structures()[0]
assert struct == CifParser(f"{TEST_FILES_DIR}/mcif/bad-unicode-gh-2947.mcif").parse_structures()[0]

# https://github.com/materialsproject/pymatgen/issues/3551
json_path = Path("test-with-path.json")
Expand Down Expand Up @@ -1559,7 +1559,7 @@ def test_charge(self):
assert super_cell.charge == 25, "Set charge not properly modifying _charge"

def test_vesta_lattice_matrix(self):
silica_zeolite = Molecule.from_file(f"{TEST_FILES_DIR}/CON_vesta.xyz")
silica_zeolite = Molecule.from_file(f"{TEST_FILES_DIR}/xyz/CON_vesta.xyz")

s_vesta = Structure(
lattice=Lattice.from_parameters(22.6840, 13.3730, 12.5530, 90, 69.479, 90, vesta=True),
Expand Down
2 changes: 1 addition & 1 deletion tests/electronic_structure/test_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def test_methods(self):

class TestPlotBZ(unittest.TestCase):
def setUp(self):
self.rec_latt = Structure.from_file(f"{TEST_FILES_DIR}/Si.cssr").lattice.reciprocal_lattice
self.rec_latt = Structure.from_file(f"{TEST_FILES_DIR}/cssr/Si.cssr").lattice.reciprocal_lattice
self.kpath = [[[0.0, 0.0, 0.0], [0.5, 0.0, 0.5], [0.5, 0.25, 0.75], [0.375, 0.375, 0.75]]]
self.labels = {
"\\Gamma": [0.0, 0.0, 0.0],
Expand Down
Loading