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

Add pymatgen.io.pwmat module #3512

Merged
merged 112 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
7a17301
Add pymatgen.io.pwmat module
lhycms Dec 13, 2023
1a8442c
pre-commit auto-fixes
pre-commit-ci[bot] Dec 13, 2023
2597804
rm unitest inside pymatgen.io.pwmat dir
lhycms Dec 13, 2023
4c1dfd2
remove unittest inside pymatgen.io.pwmat
lhycms Dec 13, 2023
4882ba7
remove try,except expression
lhycms Dec 13, 2023
8c5a33d
pre-commit auto-fixes
pre-commit-ci[bot] Dec 13, 2023
8253570
Improve code quality
lhycms Dec 13, 2023
6e2e657
Improve code quality
lhycms Dec 13, 2023
184641d
pre-commit auto-fixes
pre-commit-ci[bot] Dec 13, 2023
6d9ca97
Improve code quality: remove format expression
lhycms Dec 13, 2023
93ef0dc
Improve code quality: split long row to many short rows
lhycms Dec 13, 2023
948c81d
pre-commit auto-fixes
pre-commit-ci[bot] Dec 13, 2023
14acdfd
Improve code quality: remove format expression
lhycms Dec 13, 2023
250615d
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Dec 13, 2023
c333ae0
Improve code quality: codespell
lhycms Dec 13, 2023
a29c76d
Add pwmat fmt within Structure.from_file() and Structure.from_str()
lhycms Dec 13, 2023
13e336c
pre-commit auto-fixes
pre-commit-ci[bot] Dec 13, 2023
4d5212b
Remove abtractclass LineLocaterBase
lhycms Dec 13, 2023
9695d8c
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Dec 13, 2023
0270480
pre-commit auto-fixes
pre-commit-ci[bot] Dec 13, 2023
7c9a033
Add output file of PWmat: Report, OUT.FERMI
lhycms Dec 19, 2023
83d6fc8
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Dec 19, 2023
d0ad749
pre-commit auto-fixes
pre-commit-ci[bot] Dec 19, 2023
b4ee538
Add output file of PWmat: DOS.totalspin, DOS.spinup, DOS.spindown
lhycms Dec 19, 2023
2afb019
Add output file of PWmat: DOS.totalspin, DOS.spinup, DOS.spindown
lhycms Dec 19, 2023
3035d2c
pre-commit auto-fixes
pre-commit-ci[bot] Dec 19, 2023
655a821
Rename part to part_upper to impove code quality to pass automaticall…
lhycms Dec 19, 2023
b1a3c64
Rename part to part_upper to impove code quality to pass automaticall…
lhycms Dec 19, 2023
980699c
pre-commit auto-fixes
pre-commit-ci[bot] Dec 19, 2023
fb7d060
add OutFermi, Report, Dosspin object to __init__.py in pwmat
lhycms Dec 19, 2023
9e10a33
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Dec 19, 2023
5cb6bd9
pre-commit auto-fixes
pre-commit-ci[bot] Dec 19, 2023
2d0174e
Merge branch 'master' into master
lhycms Dec 19, 2023
b30c22f
Merge branch 'master' into master
lhycms Dec 20, 2023
23b6d4a
Improve code quality
lhycms Dec 20, 2023
28d0f57
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Dec 20, 2023
13d6b27
Add input file named gen.kpt
lhycms Dec 20, 2023
4690801
pre-commit auto-fixes
pre-commit-ci[bot] Dec 20, 2023
6f3f0d7
improve code quality
lhycms Dec 20, 2023
be70f6b
Improve code quality
lhycms Dec 20, 2023
940c981
pre-commit auto-fixes
pre-commit-ci[bot] Dec 20, 2023
9470d15
Improve code quality
lhycms Dec 20, 2023
f5d4127
Improve code quality
lhycms Dec 20, 2023
0279c87
pre-commit auto-fixes
pre-commit-ci[bot] Dec 20, 2023
455afdc
Improve code quality
lhycms Dec 20, 2023
de8b9c6
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Dec 20, 2023
fc7eab5
Improve code quality
lhycms Dec 20, 2023
3d471f0
Add high_symmetry_point
lhycms Dec 28, 2023
179ff70
pre-commit auto-fixes
pre-commit-ci[bot] Dec 28, 2023
dc2c67f
Improve code quality
lhycms Dec 28, 2023
c2ed101
Improve code quality
lhycms Dec 28, 2023
b781b8f
pre-commit auto-fixes
pre-commit-ci[bot] Dec 28, 2023
18acffb
Add test for all new features
lhycms Dec 28, 2023
04c8601
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Dec 28, 2023
94ee8eb
pre-commit auto-fixes
pre-commit-ci[bot] Dec 28, 2023
60626fe
Improve code quality
lhycms Dec 28, 2023
78c07e2
Improve code quality
lhycms Dec 28, 2023
15a78e8
pre-commit auto-fixes
pre-commit-ci[bot] Dec 28, 2023
a893f39
improve code quality
lhycms Dec 28, 2023
82ea510
Improve code quality
lhycms Dec 28, 2023
9fdc9a2
pre-commit auto-fixes
pre-commit-ci[bot] Dec 28, 2023
8873f94
Improve code quality
lhycms Dec 28, 2023
e6f9e02
Improve code quality for test
lhycms Dec 28, 2023
b7d1ac2
pre-commit auto-fixes
pre-commit-ci[bot] Dec 28, 2023
461134c
snake case variables, fix doc strings and return types
janosh Dec 28, 2023
2e0576c
Revise comments and compress the test file.
lhycms Jan 3, 2024
0db0466
pre-commit auto-fixes
pre-commit-ci[bot] Jan 3, 2024
a663c16
Improve code quality to pass test
lhycms Jan 3, 2024
d5fdf8c
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Jan 3, 2024
c87cfd4
pre-commit auto-fixes
pre-commit-ci[bot] Jan 3, 2024
6985fcd
Revise annotation again
lhycms Jan 3, 2024
48d4364
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Jan 3, 2024
7466b3c
pre-commit auto-fixes
pre-commit-ci[bot] Jan 3, 2024
6bb2c6e
Further modify the annotations
lhycms Jan 16, 2024
28fad8b
Further modify the annotations
lhycms Jan 16, 2024
e6c45c3
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Jan 16, 2024
ccafc4f
pre-commit auto-fixes
pre-commit-ci[bot] Jan 16, 2024
29213c4
Modify code according to mypy
lhycms Jan 16, 2024
6777baf
Modify code according to mypy
lhycms Jan 16, 2024
a72d215
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Jan 16, 2024
e6fcb5a
Fix mispelling according to codespell
lhycms Jan 16, 2024
8c07db4
Merge branch 'master' into master
lhycms Jan 16, 2024
7645048
Modify annotation according to mypy
lhycms Jan 16, 2024
72fff9a
Modify annotation of filename: str -> PathLike
lhycms Jan 16, 2024
e8638e2
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Jan 16, 2024
4b6ec84
Merge branch 'master' into master
lhycms Jan 16, 2024
a0f8938
Add pwmat in FileFormats
lhycms Jan 16, 2024
7854816
Change the type annotation of filename to PathLike
lhycms Jan 17, 2024
b69fd31
Change type annotation: np.array -> np.ndarray
lhycms Jan 17, 2024
a43fb34
Utilize mypy check locally to pass 21 tests for pymatgen.io.pwmat
lhycms Jan 17, 2024
4ca392b
pre-commit auto-fixes
pre-commit-ci[bot] Jan 17, 2024
e7ed20c
fix typos
janosh Jan 17, 2024
9dff811
del tests/io/pwmat/__init__.py
janosh Jan 17, 2024
a14c5aa
more informative unrecognized file extension error in Structure.from_…
janosh Jan 17, 2024
56d4f26
fnmatch compressed *.config* or *.pwmat* files
janosh Jan 17, 2024
8e3725b
compress test files
janosh Jan 17, 2024
e48b6a6
snake_case dict keys and method names
janosh Jan 17, 2024
392b4ce
don't write tmp test files to git repo
janosh Jan 17, 2024
488c299
re.escape err msg
janosh Jan 17, 2024
90cb9ef
drop filename from expected err msg
janosh Jan 17, 2024
e69169c
Add test for Structure pwmat IO format
lhycms Jan 17, 2024
634f899
Add test for Structure pwmat IO format
lhycms Jan 17, 2024
fc9145f
Merge branch 'master' into master
lhycms Jan 17, 2024
f540008
pre-commit auto-fixes
pre-commit-ci[bot] Jan 17, 2024
f76bf54
Try to pass test in win
lhycms Jan 17, 2024
d6f93cf
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Jan 17, 2024
c327dac
Merge branch 'master' into master
lhycms Jan 18, 2024
0676d72
Decompress the test file and reduce the number of lines.
lhycms Jan 18, 2024
fe765e1
Merge branch 'master' of github.com:lhycms/pymatgen
lhycms Jan 18, 2024
9cc2ea4
Add test for Structure.from_file() and Structure.to() in pwmat format
lhycms Jan 18, 2024
c6e5cad
pre-commit auto-fixes
pre-commit-ci[bot] Jan 18, 2024
503a91f
improve test_inputs.py assertions
janosh Jan 18, 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
18 changes: 15 additions & 3 deletions pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

from pymatgen.util.typing import CompositionLike, SpeciesLike

FileFormats = Literal["cif", "poscar", "cssr", "json", "yaml", "yml", "xsf", "mcsqs", "res", ""]
FileFormats = Literal["cif", "poscar", "cssr", "json", "yaml", "yml", "xsf", "mcsqs", "res", "pwmat", ""]


class Neighbor(Site):
Expand Down Expand Up @@ -2665,7 +2665,7 @@ def to(self, filename: str | Path = "", fmt: FileFormats = "", **kwargs) -> str:
fmt (str): Format to output to. Defaults to JSON unless filename
is provided. If fmt is specifies, it overrides whatever the
filename is. Options include "cif", "poscar", "cssr", "json",
"xsf", "mcsqs", "prismatic", "yaml", "yml", "fleur-inpgen".
"xsf", "mcsqs", "prismatic", "yaml", "yml", "fleur-inpgen", "pwmat".
Non-case sensitive.
**kwargs: Kwargs passthru to relevant methods. E.g., This allows
the passing of parameters like symprec to the
Expand Down Expand Up @@ -2746,6 +2746,10 @@ def to(self, filename: str | Path = "", fmt: FileFormats = "", **kwargs) -> str:
with zopen(filename, "wt", encoding="utf8") as file:
file.write(res_str)
return res_str
elif fmt == "pwmat" or fnmatch(filename.lower(), "*.pwmat") or fnmatch(filename.lower(), "*.config"):
from pymatgen.io.pwmat import AtomConfig

writer = AtomConfig(self, **kwargs)
else:
if fmt == "":
raise ValueError(f"Format not specified and could not infer from {filename=}")
Expand Down Expand Up @@ -2826,6 +2830,10 @@ def from_str( # type: ignore[override]
from pymatgen.io.res import ResIO

struct = ResIO.structure_from_str(input_string, **kwargs)
elif fmt == "pwmat":
from pymatgen.io.pwmat import AtomConfig

struct = AtomConfig.from_str(input_string, **kwargs).structure
else:
raise ValueError(f"Invalid {fmt=}, valid options are {get_args(FileFormats)}")

Expand Down Expand Up @@ -2904,8 +2912,12 @@ def from_file( # type: ignore[override]
from pymatgen.io.res import ResIO

struct = ResIO.structure_from_file(filename, **kwargs)
elif fnmatch(fname.lower(), "*.config*") or fnmatch(fname.lower(), "*.pwmat*"):
from pymatgen.io.pwmat import AtomConfig

struct = AtomConfig.from_file(filename, **kwargs).structure
else:
raise ValueError("Unrecognized file extension!")
raise ValueError(f"Unrecognized extension in {filename=}")
if sort:
struct = struct.get_sorted_structure()
if merge_tol:
Expand Down
5 changes: 5 additions & 0 deletions pymatgen/io/pwmat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""This package implements modules for input and output to and from PWmat."""
from __future__ import annotations

from .inputs import AtomConfig
from .outputs import DosSpin, Movement, OutFermi, Report
Loading
Loading