mirror of
https://github.com/triqs/dft_tools
synced 2024-12-23 04:43:42 +01:00
819fc987f0
The files from the original vasp-interface repository are reshuffled in accord with the directory structure of dft_tools. Some of the directories, such as 'test' (unit tests for the interface), 'examples' (simple examples for the development purposes) are temporarily placed into 'python/vasp' directory to avoid confusion with integral tests and examples of dft_tools.
28 lines
732 B
Python
28 lines
732 B
Python
r"""
|
|
Module defining a custom TestCase with extra functionality.
|
|
"""
|
|
|
|
import unittest
|
|
import numpy as np
|
|
|
|
class ArrayTestCase(unittest.TestCase):
|
|
"""
|
|
Custom TestCase class supporting array equality.
|
|
"""
|
|
def __init__(self, *args, **kwargs):
|
|
"""
|
|
Initializes a custom equality function for comparing numpy arrays.
|
|
"""
|
|
super(ArrayTestCase, self).__init__(*args, **kwargs)
|
|
self.addTypeEqualityFunc(np.ndarray, self.is_arrays_equal)
|
|
|
|
def is_arrays_equal(self, arr1, arr2, msg=None):
|
|
"""
|
|
Raises self.failureException is arrays arr1 and arr2
|
|
are not equal.
|
|
"""
|
|
if not np.allclose(arr1, arr2):
|
|
raise self.failureException(msg)
|
|
|
|
|