-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest_morphresolution.py
More file actions
45 lines (31 loc) · 1.16 KB
/
test_morphresolution.py
File metadata and controls
45 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import os
import numpy
import pytest
from diffpy.morph.morphs.morphresolution import MorphResolutionDamping
# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
testdata_dir = os.path.join(tests_dir, "testdata")
class TestMorphScale:
@pytest.fixture
def setup(self):
morph_file = os.path.join(testdata_dir, "ni_qmax25.cgr")
self.x_morph, self.y_morph = numpy.loadtxt(morph_file, unpack=True)
target_file = os.path.join(testdata_dir, "ni_qmax25_qdamp0.01.cgr")
self.x_target, self.y_target = numpy.loadtxt(target_file, unpack=True)
return
def test_morph(self, setup):
"""Check MorphScale.morph()"""
config = {"qdamp": 0.01}
morph = MorphResolutionDamping(config)
x_morph, y_morph, x_target, y_target = morph(
self.x_morph, self.y_morph, self.x_target, self.y_target
)
assert numpy.allclose(self.y_target, y_target)
assert numpy.allclose(y_morph, y_target)
return
# End of class TestMorphScale
if __name__ == "__main__":
TestMorphScale()
# End of file