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

Remove dead code #84

Merged
merged 7 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# File open for editing in vi
*.swp
# autogenerated by dephell
setup.py
# autogenerated by poetry2conda
Expand Down
3 changes: 0 additions & 3 deletions src/py4vasp/_data/band.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ def _spin_polarized(self):
def _dispersion(self):
return data.Dispersion.from_data(self._raw_data.dispersion)

def _kpoints(self):
return data.Kpoint.from_data(self._raw_data.dispersion.kpoints)

@property
def _projector(self):
return data.Projector.from_data(self._raw_data.projectors)
Expand Down
4 changes: 3 additions & 1 deletion src/py4vasp/_data/dielectric_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np

from py4vasp import exception
from py4vasp._data import base
from py4vasp._third_party import graph
from py4vasp._util import convert, select
Expand Down Expand Up @@ -122,7 +123,8 @@ def _update_choice(current_choice, part):
elif part in ("Im", "imag", "imaginary"):
return current_choice._replace(real_or_imag="imag")
else:
assert False
message = f"The choice {current_choice} was not understood. Please check if there are any spelling mistakes."
raise exception.IncorrectUsage(message)


def _setup_component_choices(choice):
Expand Down
4 changes: 3 additions & 1 deletion src/py4vasp/_data/dielectric_tensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright © VASP Software GmbH,
# Licensed under the Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
from py4vasp import exception
from py4vasp._data import base
from py4vasp._util import convert

Expand Down Expand Up @@ -65,4 +66,5 @@ def _description(method):
return "including local field effects"
elif method == "nscf":
return "excluding local field effects"
assert False # unknown method
message = f"The method {method} is not implemented in this version of py4vasp."
raise exception.NotImplemented(message)
2 changes: 1 addition & 1 deletion src/py4vasp/_data/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def to_dict(self):
{examples}
"""
return {
"structure": self._structure[self._steps].read(),
"stress": self._stress[self._steps],
"structure": self._structure[self._steps].read(),
}

@property
Expand Down
3 changes: 0 additions & 3 deletions src/py4vasp/_util/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,3 @@ def __getitem__(self, key):
return self._array[key]
except (ValueError, IndexError, TypeError) as err:
raise exception.IncorrectUsage(self.error_message(key, err)) from err

def __len__(self):
return len(self._array)
6 changes: 6 additions & 0 deletions tests/data/test_dielectric_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import pytest

from py4vasp import exception
from py4vasp.data import DielectricFunction


Expand Down Expand Up @@ -264,6 +265,11 @@ def test_ionic_plot_nested(ionic, Assert):
check_figure_contains_plots(fig, plots, Assert)


def test_incorrect_direction_raises_error(electronic):
with pytest.raises(exception.IncorrectUsage):
electronic.plot("incorrect")


def isotropic(tensor):
return np.trace(tensor) / 3

Expand Down
7 changes: 7 additions & 0 deletions tests/data/test_dielectric_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest

from py4vasp import exception
from py4vasp.data import DielectricTensor


Expand Down Expand Up @@ -72,6 +73,12 @@ def check_read_dielectric_tensor(dielectric_tensor, Assert):
assert actual["method"] == reference.method


def test_unknown_method(raw_data):
raw_tensor = raw_data.dielectric_tensor("unknown_method with_ion")
with pytest.raises(exception.NotImplemented):
DielectricTensor.from_data(raw_tensor).print()


def test_print_dft_tensor(dft_tensor, format_):
actual, _ = format_(dft_tensor)
check_print_dielectric_tensor(actual, dft_tensor.ref)
Expand Down