-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix plot save fig and enhance type * tweak decorator usage * plt -> fig to avoid shadowing matplotlib.pyplot as plt * fix type error for electronic_structure plotter * pin 3.12 in ci * fix sources path for src layout * split tests for cli * Revert "split tests for cli" This reverts commit f159d5e. * Revert "fix sources path for src layout" This reverts commit 3dfe21c. * recover no type check decorator, intend for another PR * Revert "recover no type check decorator, intend for another PR" This reverts commit f4dabf9. * Reapply "split tests for cli" This reverts commit b01deab. * Reapply "fix sources path for src layout" This reverts commit a7b7e25. * pin mypy for now * improve comment * add unit test for plot * also check incorrect usage
- Loading branch information
1 parent
8a4822a
commit a28e1da
Showing
8 changed files
with
132 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
@pytest.fixture | ||
def cd_tmp_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch): | ||
monkeypatch.chdir(tmp_path) | ||
return tmp_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
import subprocess | ||
from typing import TYPE_CHECKING | ||
|
||
from pymatgen.util.testing import TEST_FILES_DIR | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
def test_pmg_analyze(cd_tmp_path: Path): | ||
subprocess.run( | ||
["pmg", "analyze", f"{TEST_FILES_DIR}/io/vasp/fixtures/scan_relaxation"], | ||
check=True, | ||
) | ||
assert os.path.isfile("vasp_data.gz") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from __future__ import annotations | ||
|
||
import subprocess | ||
from typing import TYPE_CHECKING | ||
|
||
from pymatgen.util.testing import VASP_IN_DIR | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
def test_pmg_diff(cd_tmp_path: Path): | ||
subprocess.run( | ||
["pmg", "diff", "--incar", f"{VASP_IN_DIR}/INCAR", f"{VASP_IN_DIR}/INCAR_2"], | ||
check=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
import subprocess | ||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
from pymatgen.util.testing import VASP_IN_DIR, VASP_OUT_DIR | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
def test_plot_xrd(cd_tmp_path: Path): | ||
subprocess.run( | ||
["pmg", "plot", "--xrd", f"{VASP_IN_DIR}/POSCAR_Fe3O4", "--out_file", "xrd.png"], | ||
check=True, | ||
) | ||
assert os.path.isfile("xrd.png") | ||
assert os.path.getsize("xrd.png") > 1024 | ||
|
||
|
||
def test_plot_dos(cd_tmp_path: Path): | ||
subprocess.run( | ||
["pmg", "plot", "--dos", f"{VASP_OUT_DIR}/vasprun_Li_no_projected.xml.gz", "--out_file", "dos.png"], | ||
check=True, | ||
) | ||
assert os.path.isfile("dos.png") | ||
assert os.path.getsize("dos.png") > 1024 | ||
|
||
|
||
def test_plot_chgint(cd_tmp_path: Path): | ||
subprocess.run( | ||
["pmg", "plot", "--chgint", f"{VASP_OUT_DIR}/CHGCAR.Fe3O4.gz", "--out_file", "chg.png"], | ||
check=True, | ||
) | ||
assert os.path.isfile("chg.png") | ||
assert os.path.getsize("chg.png") > 1024 | ||
|
||
|
||
def test_plot_wrong_arg(cd_tmp_path: Path): | ||
with pytest.raises(subprocess.CalledProcessError) as exc_info: | ||
subprocess.run( | ||
["pmg", "plot", "--wrong", f"{VASP_OUT_DIR}/CHGCAR.Fe3O4.gz"], | ||
check=True, | ||
capture_output=True, | ||
) | ||
|
||
assert exc_info.value.returncode == 2 | ||
assert "one of the arguments -d/--dos -c/--chgint -x/--xrd is required" in exc_info.value.stderr.decode("utf-8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters