Skip to content

Commit

Permalink
Don't invoke open in Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Dec 15, 2024
1 parent 5d17288 commit 22c246c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
24 changes: 23 additions & 1 deletion abipy/ml/extxyz_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""
Tools to read data from output files generated by ab-initio codes
and generate extended XYZ files.
"""
from __future__ import annotations

Expand All @@ -25,7 +27,7 @@ class ExtxyzIOWriter:
"""
Example:
# To find all the vasprun.xml files starting from the a top-level directory, use:
# To find all the vasprun.xml files starting from a top-level directory, use:
xyz_writer = ExtxyzIOWriter.from_top(".", "vasprun.xml")
print(xyz_writer)
Expand All @@ -46,6 +48,20 @@ class ExtxyzIOWriter:
"GSR.nc",
]

@classmethod
def from_top_vasprun(cls, top: PathLike):
"""
Find all the vasprun.xml files starting from the top-level directory top.
"""
return cls(top, "vasprun.xml")

@classmethod
def from_top_gsr(cls, top: PathLike):
"""
Find all the GSR.nc files starting from the top-level directory top.
"""
return cls(top, "GSR.nc")

@classmethod
def from_top(cls, top: PathLike, ext: str):
"""
Expand Down Expand Up @@ -79,6 +95,11 @@ def __str__(self) -> str:

def write(self, xyz_filepath: PathLike, overwrite: bool = False):
"""
Write data to xyz_filepath.
Args:
xyz_filepath: Filename
overwrite: True to allow overwriting.
"""
if not overwrite and os.path.isfile(xyz_filepath):
raise RuntimeError(f"Cannot overwrite pre-existent file: {xyz_filepath=}, use overwrite=True to allow overwriting.")
Expand All @@ -89,6 +110,7 @@ def write(self, xyz_filepath: PathLike, overwrite: bool = False):

def yield_atoms(self):
"""
Generate ASE atoms.
"""
for filepath in self.filepaths:
if self.ext == "vasprun.xml":
Expand Down
4 changes: 2 additions & 2 deletions abipy/ml/tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""
Low-level tools used in abipy.ml
"""
from __future__ import annotations

Expand Down Expand Up @@ -95,5 +96,4 @@ def get_structures_labels_from_files(filepaths) -> tuple[list[Structure], dict]:
#for s in structures: print(s)
#for k, v in labels.items(): print(k, v)

return structures, labels

return structures, labels
3 changes: 1 addition & 2 deletions abipy/ppcodes/ppgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ def check_status(self):
# fr = "fully-relativistic"



class OncvGenerator(_PseudoGenerator):
"""
This object receives an input file for oncvpsp, a string
Expand Down Expand Up @@ -394,4 +393,4 @@ def check_status(self):
logger.warning("setting status to S_ERROR")
self._status = self.S_ERROR

return self._status
return self._status
7 changes: 3 additions & 4 deletions abipy/scripts/abiml.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from functools import wraps
from time import time
from abipy.core.structure import Structure
from abipy.tools.printing import print_dataframe
#from abipy.tools.printing import print_dataframe


ASE_OPTIMIZERS = aseml.ase_optimizer_cls("__all__")
Expand Down Expand Up @@ -319,8 +319,7 @@ def md(ctx, filepath, nn_name,
def neb(ctx, filepaths, nn_name,
nimages, relax_mode, fmax, pressure, optimizer, neb_method, climb,
fix_inds, fix_symbols,
workdir, verbose
):
workdir, verbose):
"""
NEB calculation with ASE and ML potential.
Expand Down Expand Up @@ -789,4 +788,4 @@ def cwf_eos(ctx, elements, nn_names,


if __name__ == "__main__":
sys.exit(main())
sys.exit(main())
2 changes: 1 addition & 1 deletion abipy/scripts/abislurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def get_epilog() -> str:
return """\
return """\
Usage example:\n
abislurm.py running => Get info on all the running jobs
Expand Down
6 changes: 3 additions & 3 deletions abipy/scripts/oncv.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def oncv_run(options):
cprint("FR calculation with input file without `_r` suffix. Will add `_r` to output files", color="yellow")

elif options.rel == "from_file":
calc_type = "scalar-relativistic"
calc_type = "scalar-relativistic"
if root.endswith("_r"): calc_type = "fully-relativistic"
if root.endswith("_nor"): calc_type = "non-relativistic"

Expand Down Expand Up @@ -326,7 +326,7 @@ def build():


def get_epilog() -> str:
return """\
return """\
Usage example:
oncv.py run H.in ==> Run oncvpsp input file (scalar relativistic mode).
Expand Down Expand Up @@ -458,4 +458,4 @@ def show_examples_and_exit(err_msg=None, error_code=1):


if __name__ == "__main__":
sys.exit(main())
sys.exit(main())
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ html: check_dot
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html || { echo "Error: Sphinx build failed"; exit 1; }
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
open $(BUILDDIR)/html/index.html || { echo "Error: Failed to open index.html"; exit 1; }
#open $(BUILDDIR)/html/index.html || { echo "Error: Failed to open index.html"; exit 1; }

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
Expand Down

0 comments on commit 22c246c

Please sign in to comment.