Skip to content

Commit

Permalink
Hide input files (#176)
Browse files Browse the repository at this point in the history
* Remove input files from API
  • Loading branch information
martin-schlipf authored Dec 9, 2024
1 parent 36a6255 commit ac58bf6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 34 deletions.
5 changes: 2 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/py4vasp/calculation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class provides a more flexible interface with which you can determine the source
"workfunction",
)
_private = ("dispersion",)
__all__ = _quantities + _input_files
__all__ = _quantities # + _input_files


path = pathlib.Path(".")
Expand All @@ -90,9 +90,9 @@ def __getattr__(attr):
module = importlib.import_module(f"py4vasp.calculation._{attr}")
class_ = getattr(module, convert.to_camelcase(attr))
return class_.from_path(".")
elif attr in (_input_files):
class_ = getattr(control, attr)
return class_(".")
# elif attr in (_input_files):
# class_ = getattr(control, attr)
# return class_(".")
else:
message = f"Could not find {attr} in the possible attributes, please check the spelling"
raise exception.MissingAttribute(message)
55 changes: 29 additions & 26 deletions src/py4vasp/calculation/_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,33 @@ def path(self):
"Return the path in which the calculation is run."
return self._path

@property
def INCAR(self):
"The INCAR file of the VASP calculation."
return self._INCAR

@INCAR.setter
def INCAR(self, incar):
self._INCAR.write(str(incar))

@property
def KPOINTS(self):
"The KPOINTS file of the VASP calculation."
return self._KPOINTS

@KPOINTS.setter
def KPOINTS(self, kpoints):
self._KPOINTS.write(str(kpoints))

@property
def POSCAR(self):
"The POSCAR file of the VASP calculation."
return self._POSCAR

@POSCAR.setter
def POSCAR(self, poscar):
self._POSCAR.write(str(poscar))
# Input files are not in current release
# @property
# def INCAR(self):
# "The INCAR file of the VASP calculation."
# return self._INCAR
#
# @INCAR.setter
# def INCAR(self, incar):
# self._INCAR.write(str(incar))
#
# @property
# def KPOINTS(self):
# "The KPOINTS file of the VASP calculation."
# return self._KPOINTS
#
# @KPOINTS.setter
# def KPOINTS(self, kpoints):
# self._KPOINTS.write(str(kpoints))
#
# @property
# def POSCAR(self):
# "The POSCAR file of the VASP calculation."
# return self._POSCAR
#
# @POSCAR.setter
# def POSCAR(self, poscar):
# self._POSCAR.write(str(poscar))


def _add_all_refinement_classes(calc, add_single_class):
Expand Down Expand Up @@ -155,6 +156,8 @@ def _add_to_documentation(calc, name):


def _add_input_files(calc):
return calc
# Input files are not in current release
for name in calculation._input_files:
file_ = getattr(control, name)(calc.path())
setattr(calc, f"_{name}", file_)
Expand Down
2 changes: 2 additions & 0 deletions tests/calculation/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_all_attributes(mock_access):
mock_access.return_value.__enter__.assert_not_called()


@pytest.mark.skip("Input files are not included in current release.")
def test_input_files_from_path():
with patch("py4vasp._control.base.InputFile.__init__", return_value=None) as mock:
calculation = Calculation.from_path("test_path")
Expand All @@ -59,6 +60,7 @@ def test_input_files_from_path():
check_all_input_files(calculation)


@pytest.mark.skip("Input files are not included in current release.")
def test_input_files_from_file():
with patch("py4vasp._control.base.InputFile.__init__", return_value=None) as mock:
calculation = Calculation.from_file("test_file")
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,8 @@ def _partial_charge(selection):
else:
spin_dimension = 1
grid = raw.VaspData(tuple(reversed(grid_dim)))
gaussian_charge = np.zeros((len(kpoints), len(bands), spin_dimension, *grid_dim))
charge_shape = (len(kpoints), len(bands), spin_dimension, *grid_dim)
gaussian_charge = np.zeros(charge_shape)
if not _is_core():
cov = grid_dim[0] / 10 # standard deviation
z = np.arange(grid_dim[0]) # z range
Expand Down

0 comments on commit ac58bf6

Please sign in to comment.