diff --git a/docs/coverage-badge.svg b/docs/coverage-badge.svg
index d3ffa3d..5125d93 100644
--- a/docs/coverage-badge.svg
+++ b/docs/coverage-badge.svg
@@ -1 +1 @@
-
+
diff --git a/docs/tests-badge.svg b/docs/tests-badge.svg
index 8a38d99..28524d3 100644
--- a/docs/tests-badge.svg
+++ b/docs/tests-badge.svg
@@ -1 +1 @@
-
+
diff --git a/ramannoodle/exceptions.py b/ramannoodle/exceptions.py
index 80c79b3..814fbdb 100644
--- a/ramannoodle/exceptions.py
+++ b/ramannoodle/exceptions.py
@@ -56,6 +56,14 @@ def get_type_error(name: str, value: Any, correct_type: str) -> TypeError:
return TypeError(f"{name} should have type {correct_type}, not {wrong_type}")
+def get_shape_error(
+ name: str, array: NDArray, desired_shape: Sequence[int | None]
+) -> ValueError:
+ """Return ValueError for an ndarray with the wrong shape."""
+ shape_spec = f"{_shape_string(array.shape)} != {_shape_string(desired_shape)}"
+ return ValueError(f"{name} has wrong shape: {shape_spec}")
+
+
def verify_ndarray(name: str, array: NDArray) -> None:
"""Verify type of NDArray .
@@ -81,11 +89,16 @@ def verify_ndarray_shape(
"""
try:
if len(shape) != array.ndim:
- shape_spec = f"{_shape_string(array.shape)} != {_shape_string(shape)}"
- raise ValueError(f"{name} has wrong shape: {shape_spec}")
+ raise get_shape_error(name, array, shape)
for d1, d2 in zip(array.shape, shape, strict=True):
if d2 is not None and d1 != d2:
- shape_spec = f"{_shape_string(array.shape)} != {_shape_string(shape)}"
- raise ValueError(f"{name} has wrong shape: {shape_spec}")
+ raise get_shape_error(name, array, shape)
except AttributeError as exc:
raise get_type_error(name, array, "ndarray") from exc
+
+
+def verify_positions(name: str, array: NDArray) -> None:
+ """Verify fractional positions according to dimensions and boundary conditions."""
+ verify_ndarray_shape(name, array, (None, 3))
+ if (0 > array).any() or (array > 1.0).any():
+ raise ValueError(f"{name} has coordinates that are not between 0 and 1")
diff --git a/ramannoodle/symmetry/__init__.py b/ramannoodle/symmetry/__init__.py
index 64be748..16d3d79 100644
--- a/ramannoodle/symmetry/__init__.py
+++ b/ramannoodle/symmetry/__init__.py
@@ -35,7 +35,9 @@ def __init__( # pylint: disable=too-many-arguments
) -> None:
verify_ndarray_shape("atomic_numbers", atomic_numbers, (None,))
verify_ndarray_shape("lattice", lattice, (3, 3))
- verify_ndarray_shape("fractional_positions", fractional_positions, (None, 3))
+ verify_ndarray_shape(
+ "fractional_positions", fractional_positions, (len(atomic_numbers), 3)
+ )
self._atomic_numbers = atomic_numbers
self._lattice = lattice
@@ -79,7 +81,7 @@ def get_equivalent_displacements(
transform the parameter `displacements` into that degree of freedom.
"""
- assert (displacement >= -0.5).all() and (displacement <= 0.5).all()
+ displacement = symmetry_utils.apply_pbc_displacement(displacement)
ref_positions = symmetry_utils.displace_fractional_positions(
self._fractional_positions, displacement
@@ -152,9 +154,9 @@ def get_cartesian_displacement(
fractional_displacement
2D array with shape (N,3) where N is the number of atoms
"""
- assert (fractional_displacement >= -0.5).all() and (
- fractional_displacement <= 0.5
- ).all()
+ fractional_displacement = symmetry_utils.apply_pbc_displacement(
+ fractional_displacement
+ )
return fractional_displacement @ self._lattice
diff --git a/ramannoodle/symmetry/symmetry_utils.py b/ramannoodle/symmetry/symmetry_utils.py
index f1071b1..426a819 100644
--- a/ramannoodle/symmetry/symmetry_utils.py
+++ b/ramannoodle/symmetry/symmetry_utils.py
@@ -1,20 +1,54 @@
"""Utility functions relevant to symmetry."""
+from typing import Iterable
+
import numpy as np
from numpy.typing import NDArray
+from ..exceptions import (
+ get_type_error,
+ SymmetryException,
+ verify_positions,
+ get_shape_error,
+)
+
def are_collinear(vector_1: NDArray[np.float64], vector_2: NDArray[np.float64]) -> bool:
- """Return whether or not two vectors are collinear."""
- vector_1_copy = vector_1 / np.linalg.norm(vector_1)
- vector_2_copy = vector_2 / np.linalg.norm(vector_2)
- dot_product = vector_1_copy.dot(vector_2_copy)
- result: bool = np.isclose(dot_product, 1).all() or np.isclose(dot_product, -1).all()
- return result
+ """Return whether or not two vectors are collinear.
+
+ Parameters
+ ----------
+ vector_1
+ ndarray with shape (M,)
+ vector_2
+ ndarray with shape (M,)
+
+ Raises
+ ------
+ TypeError
+ ValueError
+
+ """
+ try:
+ vector_1 = vector_1 / float(np.linalg.norm(vector_1))
+ except TypeError as exc:
+ raise get_type_error("vector_1", vector_1, "ndarray") from exc
+ try:
+ vector_2 = vector_2 / float(np.linalg.norm(vector_2))
+ except TypeError as exc:
+ raise get_type_error("vector_2", vector_2, "ndarray") from exc
+ try:
+ dot_product = vector_1.dot(vector_2)
+ except ValueError as exc:
+ length_expr = f"{len(vector_1)} != {len(vector_2)}"
+ raise ValueError(
+ f"vector_1 and vector_2 have different lengths: {length_expr}"
+ ) from exc
+ return bool(np.isclose(dot_product, 1).all() or np.isclose(dot_product, -1).all())
def is_orthogonal_to_all(
- vector_1: NDArray[np.float64], vectors: list[NDArray[np.float64]]
+ vector_1: NDArray[np.float64], vectors: Iterable[NDArray[np.float64]]
) -> int:
"""Check whether a given vector is orthogonal to a list of others.
@@ -23,23 +57,31 @@ def is_orthogonal_to_all(
int
first index of non-orthogonal vector, otherwise -1
+ Raises
+ ------
+ TypeError
+
"""
- # This implementation could be made more efficient but readability would
- # be sacrificed .
- vector_1_copy = vector_1 / np.linalg.norm(vector_1)
+ # This implementation could be made more efficient.
+ try:
+ vector_1 = vector_1 / float(np.linalg.norm(vector_1))
+ except TypeError as exc:
+ raise get_type_error("vector_1", vector_1, "ndarray") from exc
for index, vector_2 in enumerate(vectors):
- vector_2_copy = vector_2 / np.linalg.norm(vector_2)
- if not np.isclose(
- np.dot(vector_1_copy.flatten(), vector_2_copy.flatten()) + 1, 1
- ).all():
+ try:
+ vector_2 = vector_2 / np.linalg.norm(vector_2)
+ except TypeError as exc:
+ raise get_type_error(f"vectors[{index}]", vector_2, "ndarray") from exc
+
+ if not np.isclose(np.dot(vector_1.flatten(), vector_2.flatten()) + 1, 1).all():
return index
return -1
def is_collinear_with_all(
- vector_1: NDArray[np.float64], vectors: list[NDArray[np.float64]]
+ vector_1: NDArray[np.float64], vectors: Iterable[NDArray[np.float64]]
) -> int:
"""Check if a given vector is collinear to a list of others.
@@ -49,8 +91,7 @@ def is_collinear_with_all(
first index of non-collinear vector, otherwise -1
"""
- # This implementation could be made more efficient but readability would
- # be sacrificed.
+ # This implementation could be made more efficient.
for index, vector_2 in enumerate(vectors):
if not are_collinear(vector_1.flatten(), vector_2.flatten()):
return index
@@ -69,8 +110,7 @@ def is_non_collinear_with_all(
first index of collinear vector, otherwise -1
"""
- # This implementation could be made more efficient but readability would
- # be sacrificed.
+ # This implementation could be made more efficient.
for index, vector_2 in enumerate(vectors):
if are_collinear(vector_1.flatten(), vector_2.flatten()):
return index
@@ -83,11 +123,17 @@ def compute_permutation_matrices(
translations: NDArray[np.float64],
fractional_positions: NDArray[np.float64],
) -> NDArray[np.float64]:
- """Expresses a series of rotation/translations as permutation matrices."""
+ """Expresses a series of rotation/translations as permutation matrices.
+
+ Raises
+ ------
+ SymmetryException
+
+ """
permutation_matrices = []
for rotation, translation in zip(rotations, translations):
permutation_matrices.append(
- get_fractional_positions_permutation_matrix(
+ _get_fractional_positions_permutation_matrix(
fractional_positions,
transform_fractional_positions(
fractional_positions, rotation, translation
@@ -97,14 +143,19 @@ def compute_permutation_matrices(
return np.array(permutation_matrices)
-def get_fractional_positions_permutation_matrix(
+def _get_fractional_positions_permutation_matrix(
reference: NDArray[np.float64], permuted: NDArray[np.float64]
) -> NDArray[np.float64]:
- """Calculate a permutation matrix given permuted fractional positions."""
- assert (0 <= reference).all() and (reference <= 1.0).all()
- assert (0 <= permuted).all() and (permuted <= 1.0).all()
+ """Calculate a permutation matrix given permuted fractional positions.
+
+ Raises
+ ------
+ SymmetryException
+ """
+ reference = apply_pbc(reference)
+ permuted = apply_pbc(permuted)
- # Perhaps not the best implementation, but it'll do for now
+ # This implementation is VERY slow.
permutation_matrix = np.zeros((len(reference), len(reference)))
for ref_index, ref_position in enumerate(reference):
@@ -114,7 +165,9 @@ def get_fractional_positions_permutation_matrix(
if distance < 0.001:
permutation_matrix[ref_index][permuted_index] = 1
break
- assert np.isclose(np.sum(permutation_matrix, axis=1), 1).all()
+
+ if not np.isclose(np.sum(permutation_matrix, axis=1), 1).all():
+ raise SymmetryException("permutation matrix could not be found")
return permutation_matrix
@@ -123,11 +176,22 @@ def transform_fractional_positions(
rotation: NDArray[np.float64],
translation: NDArray[np.float64],
) -> NDArray[np.float64]:
- """Transform fractional coordinates under periodic boundary conditions."""
- assert (0 <= positions).all() and (positions <= 1.0).all()
- rotated = positions @ rotation
- rotated[rotated < 0.0] += 1
- rotated[rotated > 1.0] -= 1
+ """Transform fractional coordinates under periodic boundary conditions.
+
+ Raises
+ ------
+ TypeError
+ ValueError
+ """
+ verify_positions("positions", positions)
+ positions = apply_pbc(positions)
+ try:
+ rotated = positions @ rotation
+ except TypeError as exc:
+ raise get_type_error("rotation", rotation, "ndarray") from exc
+ except ValueError as exc:
+ raise get_shape_error("rotation", rotation, (3, 3)) from exc
+ rotated = apply_pbc(rotated)
return displace_fractional_positions(rotated, translation)
@@ -136,12 +200,10 @@ def displace_fractional_positions(
displacement: NDArray[np.float64],
) -> NDArray[np.float64]:
"""Add fractional positions together under periodic boundary conditions."""
- assert (0 <= positions).all() and (positions <= 1.0).all()
+ positions = apply_pbc(positions)
+ displacement = apply_pbc_displacement(displacement)
- result = positions + displacement
- result[result < 0.0] += 1
- result[result > 1.0] -= 1
- return result
+ return apply_pbc(positions + displacement)
def calculate_displacement(
@@ -153,10 +215,23 @@ def calculate_displacement(
Returns a displacement.
"""
- assert (0 <= positions_1).all() and (positions_1 <= 1.0).all()
- assert (0 <= positions_2).all() and (positions_2 <= 1.0).all()
+ positions_1 = apply_pbc(positions_1)
+ positions_2 = apply_pbc(positions_2)
+
+ return apply_pbc_displacement(positions_1 - positions_2)
+
+
+def apply_pbc(positions: NDArray[np.float64]) -> NDArray[np.float64]:
+ """Return fractional positions such that all coordinates are b/t 0 and 1."""
+ try:
+ return positions - positions // 1
+ except TypeError as exc:
+ raise get_type_error("positions", positions, "ndarray") from exc
+
- difference = positions_1 - positions_2
- difference[difference > 0.5] -= 1.0
- difference[difference < -0.5] += 1.0
- return difference
+def apply_pbc_displacement(displacement: NDArray[np.float64]) -> NDArray[np.float64]:
+ """Return fractional displacement such as all coordinates are b/t -0.5 and 0.5."""
+ try:
+ return np.where(displacement % 1 > 0.5, displacement % 1 - 1, displacement % 1)
+ except TypeError as exc:
+ raise get_type_error("displacement", displacement, "ndarray") from exc
diff --git a/test/tests/test_interpolation.py b/test/tests/test_interpolation.py
index f6b7444..59148f8 100644
--- a/test/tests/test_interpolation.py
+++ b/test/tests/test_interpolation.py
@@ -24,7 +24,7 @@
],
)
def test_find_duplicates(vectors: NDArray[np.float64], known: bool) -> None:
- """Test for find_duplicates (success)."""
+ """Test find_duplicates (normal)."""
assert find_duplicates(vectors) == known
@@ -38,7 +38,7 @@ def test_find_duplicates(vectors: NDArray[np.float64], known: bool) -> None:
def test_find_duplicates_exception(
vectors: NDArray[np.float64], exception_type: Type[Exception], in_reason: str
) -> None:
- """Test for find_duplicates (exception)."""
+ """Test find_duplicates (exception)."""
with pytest.raises(exception_type) as error:
find_duplicates(vectors)
assert in_reason in str(error.value)
@@ -246,7 +246,7 @@ def test_add_dof_from_files_exception(
exception_type: Type[Exception],
in_reason: str,
) -> None:
- """Test exceptions in add_dof_from_files."""
+ """Test add_dof_from_files (exception)."""
symmetry = outcar_symmetry_fixture
model = InterpolationPolarizabilityModel(symmetry, np.zeros((3, 3)))
with pytest.raises(exception_type) as error:
diff --git a/test/tests/test_spectrum.py b/test/tests/test_spectrum.py
index 6d1bda1..1def032 100644
--- a/test/tests/test_spectrum.py
+++ b/test/tests/test_spectrum.py
@@ -71,7 +71,7 @@ def test_spectrum(
data_directory: str,
dof_eps_outcars: list[str],
) -> None:
- """Test a spectrum calculation."""
+ """Test a full spectrum calculation."""
# Setup model
symmetry = outcar_symmetry_fixture
_, polarizability = io.read_positions_and_polarizability(
@@ -122,7 +122,7 @@ def test_convolve_intensities(
known_gaussian_spectrum_path: str,
known_lorentzian_spectrum_path: str,
) -> None:
- """Test convolutions."""
+ """Test convolve_intensities (normal)."""
with np.load(spectrum_path) as spectrum:
wavenumbers = spectrum["wavenumbers"]
intensities = spectrum["intensities"]
@@ -232,7 +232,7 @@ def test_convolve_intensities_exception( # pylint: disable=too-many-arguments
exception_type: Type[Exception],
in_reason: str,
) -> None:
- """Test exceptions raised by convolve_intensities."""
+ """Test convolve_intensities (exception)."""
with pytest.raises(exception_type) as error:
convolve_intensities(wavenumbers, intensities, function, width, out_wavenumbers)
assert in_reason in str(error.value)
@@ -261,13 +261,13 @@ def test_convolve_intensities_exception( # pylint: disable=too-many-arguments
),
],
)
-def test_get_bose_einstein_correction_exceptions(
+def test_get_bose_einstein_correction_exception(
wavenumbers: NDArray[np.float64],
temperature: float,
exception_type: Type[Exception],
in_reason: str,
) -> None:
- """Test exceptions raised by get_bose_einstein_correction."""
+ """Test get_bose_einstein_correction (exception)."""
with pytest.raises(exception_type) as error:
get_bose_einstein_correction(wavenumbers, temperature)
assert in_reason in str(error.value)
@@ -302,7 +302,7 @@ def test_get_laser_correction(
exception_type: Type[Exception],
in_reason: str,
) -> None:
- """Test exceptions raised by get_laser_correction."""
+ """Test get_laser_correction (exception)."""
with pytest.raises(exception_type) as error:
get_laser_correction(wavenumbers, laser_wavenumber)
assert in_reason in str(error.value)
diff --git a/test/tests/test_symmetry.py b/test/tests/test_symmetry.py
index 90f3025..52a3433 100644
--- a/test/tests/test_symmetry.py
+++ b/test/tests/test_symmetry.py
@@ -1,14 +1,20 @@
"""Testing for symmetry-related routines."""
+from typing import Type
+
import numpy as np
from numpy.typing import NDArray
import pytest
from ramannoodle.symmetry.symmetry_utils import (
+ is_collinear_with_all,
+ is_non_collinear_with_all,
are_collinear,
is_orthogonal_to_all,
- get_fractional_positions_permutation_matrix,
+ _get_fractional_positions_permutation_matrix,
+ apply_pbc,
+ apply_pbc_displacement,
)
from ramannoodle.symmetry import StructuralSymmetry
@@ -25,10 +31,45 @@
def test_are_collinear(
vector_1: NDArray[np.float64], vector_2: NDArray[np.float64], known: bool
) -> None:
- """Test."""
+ """Test are_collinear (normal)."""
assert are_collinear(vector_1, vector_2) == known
+@pytest.mark.parametrize(
+ "vector_1, vector_2, exception_type, in_reason",
+ [
+ (
+ np.array([-5.0, -5.0, 1.0]),
+ [1.0, 1.0, 0.0],
+ TypeError,
+ "vector_2 should have type ndarray, not list",
+ ),
+ (
+ [0.0, 0.0, -1.0],
+ np.array([1.0, 0.0, 0.0]),
+ TypeError,
+ "vector_1 should have type ndarray, not list",
+ ),
+ (
+ np.array([0.0, 0.0, 6.0, 7.9]),
+ np.array([0.0, 0.0, -3.0]),
+ ValueError,
+ "vector_1 and vector_2 have different lengths: 4 != 3",
+ ),
+ ],
+)
+def test_are_collinear_exception(
+ vector_1: NDArray[np.float64],
+ vector_2: NDArray[np.float64],
+ exception_type: Type[Exception],
+ in_reason: str,
+) -> None:
+ """Test are_collinear (exception)."""
+ with pytest.raises(exception_type) as error:
+ are_collinear(vector_1, vector_2)
+ assert in_reason in str(error.value)
+
+
@pytest.mark.parametrize(
"vector_1, vectors, known",
[
@@ -40,13 +81,53 @@ def test_are_collinear(
(np.array([1.0, 1.0, 0.0]), np.array([[0.0, 0.0, 1.0], [-1.0, 1.0, 0.0]]), -1),
],
)
-def test_check_orthogonal(
+def test_is_orthogonal_to_all(
vector_1: NDArray[np.float64], vectors: list[NDArray[np.float64]], known: int
) -> None:
- """Test."""
+ """Test is_orthogonal_to_all (normal)."""
assert is_orthogonal_to_all(vector_1, vectors) == known
+@pytest.mark.parametrize(
+ "vector_1, vectors, known",
+ [
+ (
+ np.array([1.0, 0.0, 0.0]),
+ np.array([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [-1.0, -1.0, 0.0]]),
+ 0,
+ ),
+ (np.array([1.0, 1.0, 0.0]), np.array([[2.0, 2.0, 0.0], [-1.0, -1.0, 0.0]]), -1),
+ ],
+)
+def test_is_collinear_with_all(
+ vector_1: NDArray[np.float64], vectors: list[NDArray[np.float64]], known: int
+) -> None:
+ """Test is_collinear_with_all (normal)."""
+ assert is_collinear_with_all(vector_1, vectors) == known
+
+
+@pytest.mark.parametrize(
+ "vector_1, vectors, known",
+ [
+ (
+ np.array([1.0, 0.0, 0.0]),
+ np.array([[0.0, 1.0, 0.0], [80.0, 0.0, 1.0], [-1.0, -1.0, 0.0]]),
+ -1,
+ ),
+ (
+ np.array([1.0, 1.0, 0.0]),
+ np.array([[2.0, 2.0, 0.0], [-1.0, -1.0, 5.0]]),
+ 0,
+ ),
+ ],
+)
+def test_is_non_collinear_with_all(
+ vector_1: NDArray[np.float64], vectors: list[NDArray[np.float64]], known: int
+) -> None:
+ """Test is_non_collinear_with_all (normal)."""
+ assert is_non_collinear_with_all(vector_1, vectors) == known
+
+
@pytest.mark.parametrize(
"outcar_symmetry_fixture, known_nonequivalent_atoms,"
"known_orthogonal_displacements, known_displacements_shape",
@@ -63,7 +144,7 @@ def test_structural_symmetry(
known_orthogonal_displacements: int,
known_displacements_shape: list[int],
) -> None:
- """Test."""
+ """Test StructuralSymmetry (normal)."""
# Equivalent atoms test
symmetry = outcar_symmetry_fixture
assert symmetry.get_num_nonequivalent_atoms() == known_nonequivalent_atoms
@@ -98,7 +179,81 @@ def test_get_fractional_positions_permutation_matrix(
permuted: NDArray[np.float64],
known: NDArray[np.float64],
) -> None:
- """Test."""
+ """Test _get_fractional_positions_permutation_matrix (normal)."""
assert np.isclose(
- get_fractional_positions_permutation_matrix(reference, permuted), known
+ _get_fractional_positions_permutation_matrix(reference, permuted), known
).all()
+
+
+@pytest.mark.parametrize(
+ "positions, known",
+ [
+ (np.array([0.2, 0.3, 0]), np.array([0.2, 0.3, 0])),
+ (np.array([1.2, 1.3, 1.8]), np.array([0.2, 0.3, 0.8])),
+ (np.array([-6.2, -0.3, -0.4]), np.array([0.8, 0.7, 0.6])),
+ ],
+)
+def test_apply_pbc(positions: NDArray[np.float64], known: NDArray[np.float64]) -> None:
+ """Test apply_pbc (normal)."""
+ assert np.isclose(apply_pbc(positions), known).all()
+
+
+@pytest.mark.parametrize(
+ "displacement, known",
+ [
+ (np.array([0.2, 0.3, 0.4]), np.array([0.2, 0.3, 0.4])),
+ (np.array([1.8, -0.6, 0]), np.array([-0.2, 0.4, 0])),
+ (np.array([-4.51, -0.3, 9.6]), np.array([0.49, -0.3, -0.4])),
+ ],
+)
+def test_apply_pbc_displacement(
+ displacement: NDArray[np.float64], known: NDArray[np.float64]
+) -> None:
+ """Test test_apply_pbc_displacement (normal)."""
+ assert np.isclose(apply_pbc_displacement(displacement), known).all()
+
+
+@pytest.mark.parametrize(
+ "atomic_numbers, lattice, fractional_positions, exception_type, in_reason",
+ [
+ (
+ (1, 2, 3, 4),
+ np.diag([1, 1, 1]),
+ np.zeros((4, 3)),
+ TypeError,
+ "atomic_numbers should have type ndarray, not tuple",
+ ),
+ (
+ np.array((1, 2, 3, 4)),
+ np.diag([1, 1]),
+ np.zeros((4, 3)),
+ ValueError,
+ "lattice has wrong shape: (2,2) != (3,3)",
+ ),
+ (
+ np.array((1, 2, 3, 4)),
+ np.diag([1, 1, 1]),
+ np.zeros((4, 2)),
+ ValueError,
+ "fractional_positions has wrong shape: (4,2) != (4,3)",
+ ),
+ (
+ np.array((1, 2, 3, 4)),
+ np.diag([1, 1, 1]),
+ np.zeros((3, 3)),
+ ValueError,
+ "fractional_positions has wrong shape: (3,3) != (4,3)",
+ ),
+ ],
+)
+def test_structural_symmetry_exception(
+ atomic_numbers: NDArray[np.int32],
+ lattice: NDArray[np.float64],
+ fractional_positions: NDArray[np.float64],
+ exception_type: Type[Exception],
+ in_reason: str,
+) -> None:
+ """Test StructuralSymmetry (exception)."""
+ with pytest.raises(exception_type) as error:
+ StructuralSymmetry(atomic_numbers, lattice, fractional_positions)
+ assert in_reason in str(error.value)
diff --git a/test/tests/test_vasp.py b/test/tests/test_vasp.py
index 45a6e10..7d7bad3 100644
--- a/test/tests/test_vasp.py
+++ b/test/tests/test_vasp.py
@@ -35,7 +35,7 @@ def test_read_phonons_from_outcar(
known_first_displacement: NDArray[np.float64],
known_last_displacement: NDArray[np.float64],
) -> None:
- """Test."""
+ """Test read_phonons for outcar (normal)."""
phonons = read_phonons(outcar_path_fixture, file_format="outcar")
known_degrees_of_freedom = known_num_atoms * 3
diff --git a/test/tests/test_vasp_utils.py b/test/tests/test_vasp_utils.py
index 6de34ff..8bd6349 100644
--- a/test/tests/test_vasp_utils.py
+++ b/test/tests/test_vasp_utils.py
@@ -23,7 +23,7 @@
],
)
def test_get_atomic_symbol_from_potcar_line(potcar_line: str, known: str) -> None:
- """Test."""
+ """Test get_atomic_symbol_from_potcar_line (normal)."""
result = vasp_utils._get_atomic_symbol_from_potcar_line(potcar_line)
assert result == known
@@ -35,8 +35,8 @@ def test_get_atomic_symbol_from_potcar_line(potcar_line: str, known: str) -> Non
("blah"),
],
)
-def test_fail_get_atomic_symbol_from_potcar_line(potcar_line: str) -> None:
- """Test."""
+def test_get_atomic_symbol_from_potcar_line_exception(potcar_line: str) -> None:
+ """Test get_atomic_symbol_from_potcar_line (exception)."""
with pytest.raises(ValueError):
vasp_utils._get_atomic_symbol_from_potcar_line(potcar_line)
@@ -50,7 +50,7 @@ def test_read_atomic_symbols_from_outcar(
outcar_file_fixture: TextIO, # pylint: disable=redefined-outer-name
known: list[str],
) -> None:
- """Test."""
+ """Test _read_atomic_symbols_from_outcar (normal)."""
atomic_symbols = vasp_utils._read_atomic_symbols_from_outcar(outcar_file_fixture)
assert atomic_symbols == known
@@ -71,7 +71,7 @@ def test_read_cartesian_positions_from_outcar(
known_first_position: NDArray[np.float64],
known_last_position: NDArray[np.float64],
) -> None:
- """Test."""
+ """Test _read_cartesian_positions_from_outcar (normal)."""
cartesian_positions = vasp_utils._read_cartesian_positions_from_outcar(
outcar_file_fixture, EPS_OUTCAR_NUM_ATOMS
)
@@ -97,7 +97,7 @@ def test_read_fractional_positions_from_outcar(
known_first_position: NDArray[np.float64],
known_last_position: NDArray[np.float64],
) -> None:
- """Test."""
+ """Test _read_fractional_positions_from_outcar (normal)."""
fractional_positions = vasp_utils._read_fractional_positions_from_outcar(
outcar_file_fixture, EPS_OUTCAR_NUM_ATOMS
)
@@ -127,7 +127,7 @@ def test_read_polarizability_from_outcar(
outcar_file_fixture: TextIO, # pylint: disable=redefined-outer-name
known_polarizability: NDArray[np.float64],
) -> None:
- """Test."""
+ """Test _read_polarizability_from_outcar (normal)."""
polarizability = vasp_utils._read_polarizability_from_outcar(outcar_file_fixture)
assert np.isclose(polarizability, known_polarizability).all()
@@ -162,6 +162,6 @@ def test_read_polarizability_from_outcar(
def test_read_lattice_from_outcar(
outcar_file_fixture: TextIO, known_lattice: NDArray[np.float64]
) -> None:
- """Test."""
+ """Test _read_lattice_from_outcar (normal)."""
result = vasp_utils._read_lattice_from_outcar(outcar_file_fixture)
assert np.isclose(result, known_lattice).all()