-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest_morphscale.py
More file actions
45 lines (31 loc) · 1.06 KB
/
test_morphscale.py
File metadata and controls
45 lines (31 loc) · 1.06 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.morphscale import MorphScale
# 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):
self.x_morph = numpy.arange(0.01, 5, 0.01)
self.y_morph = numpy.ones_like(self.x_morph)
self.x_target = numpy.arange(0.01, 5, 0.01)
self.y_target = 3 * numpy.ones_like(self.x_target)
return
def test_morph(self, setup):
"""Check MorphScale.morph()"""
config = {"scale": 2.0}
morph = MorphScale(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(2 * self.y_morph, y_morph)
assert numpy.allclose(self.y_target, y_target)
return
# End of class TestMorphScale
if __name__ == "__main__":
TestMorphScale()
# End of file