FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
diffpy.morph/tests/test_morphsmear.py at migration · diffpy/diffpy.morph · GitHub
diffpy
diffpy.morph
Repository navigation
Code
Issues
18
(18)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
diffpy.morph
/
tests
/
test_morphsmear.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (40 loc) · 1.39 KB
Breadcrumbs
diffpy.morph
/
tests
/
test_morphsmear.py
Copy path
File metadata and controls
56 lines (40 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
import
os
import
numpy
import
pytest
from
diffpy
.
morph
.
morphs
.
morphsmear
import
MorphSmear
# 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
TestMorphSmear
:
@
pytest
.
fixture
def
setup
(
self
):
self
.
smear
=
0.1
self
.
r0
=
7
*
numpy
.
pi
/
22.0
*
2
self
.
x_morph
=
numpy
.
arange
(
0.01
,
5
,
0.01
)
self
.
y_morph
=
numpy
.
exp
(
-
0.5
*
((
self
.
x_morph
-
self
.
r0
)
/
self
.
smear
)
**
2
)
self
.
x_target
=
self
.
x_morph
.
copy
()
self
.
y_target
=
self
.
x_target
.
copy
()
return
def
test_morph
(
self
,
setup
):
"""Check MorphSmear.morph()"""
morph
=
MorphSmear
()
morph
.
smear
=
0.15
x_morph
,
y_morph
,
x_target
,
y_target
=
morph
(
self
.
x_morph
,
self
.
y_morph
,
self
.
x_target
,
self
.
y_target
)
# Target should be unchanged
assert
numpy
.
allclose
(
self
.
y_target
,
y_target
)
# Compare to broadened Gaussian
sigbroad
=
(
self
.
smear
**
2
+
morph
.
smear
**
2
)
**
0.5
ysmear
=
numpy
.
exp
(
-
0.5
*
((
self
.
x_morph
-
self
.
r0
)
/
sigbroad
)
**
2
)
ysmear
*=
self
.
smear
/
sigbroad
assert
numpy
.
allclose
(
ysmear
,
y_morph
)
return
# End of class TestMorphSmear
if
__name__
==
"__main__"
:
TestMorphSmear
()
# End of file
Back
|
FazBrowse Home
|
New Git URL