FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
diffpy.pdfgui/tests/test_parameter.py at main · diffpy/diffpy.pdfgui · GitHub
diffpy
diffpy.pdfgui
Repository navigation
Code
Issues
24
(24)
Pull requests
2
(2)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
diffpy.pdfgui
/
tests
/
test_parameter.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (67 loc) · 2.51 KB
Breadcrumbs
diffpy.pdfgui
/
tests
/
test_parameter.py
Copy path
File metadata and controls
81 lines (67 loc) · 2.51 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
##############################################################################
#
# diffpy.pdfgui Complex Modeling Initiative
# (c) 2019 Brookhaven Science Associates,
# Brookhaven National Laboratory.
# All rights reserved.
#
# File coded by: Pavol Juhas
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE.txt for license information.
#
##############################################################################
"""Unit tests for the Parameter class."""
import
unittest
import
wx
from
testutils
import
GUITestCase
,
datafile
from
diffpy
.
pdfgui
.
control
.
controlerrors
import
ControlKeyError
,
ControlTypeError
from
diffpy
.
pdfgui
.
control
.
parameter
import
Parameter
from
diffpy
.
pdfgui
.
gui
.
mainframe
import
MainFrame
# ----------------------------------------------------------------------------
class
TestParameter
(
GUITestCase
):
@
classmethod
def
setUpClass
(
cls
):
GUITestCase
.
setUpClass
()
GUITestCase
.
setCmdArgs
([
datafile
(
"lcmo.ddp"
)])
cls
.
app
=
wx
.
App
()
cls
.
frame
=
MainFrame
(
None
,
-
1
,
""
)
tree
=
cls
.
frame
.
treeCtrlMain
fits
=
tree
.
GetChildren
(
tree
.
root
)
cls
.
frame
.
makeTreeSelection
(
fits
[
0
])
return
@
classmethod
def
tearDownClass
(
cls
):
cls
.
frame
.
Close
()
cls
.
app
.
Destroy
()
GUITestCase
.
tearDownClass
()
return
def
setUp
(
self
):
self
.
fitting
=
self
.
frame
.
rightPanel
.
fit
return
def
test___init__
(
self
):
"check Parameter.__init__"
p
=
Parameter
(
3
,
2.2
)
self
.
assertEqual
(
3
,
p
.
idx
)
self
.
assertIsNone
(
p
.
refined
)
self
.
assertEqual
(
2.2
,
p
.
initialValue
())
p100
=
Parameter
(
100
,
self
.
fitting
)
self
.
assertAlmostEqual
(
0.7957747
,
p100
.
initialValue
(),
6
)
p102
=
Parameter
(
102
,
"=fit-d300:102"
)
self
.
assertAlmostEqual
(
1.1811493
,
p102
.
initialValue
(),
6
)
self
.
assertRaises
(
ControlTypeError
,
Parameter
,
1
,
None
)
return
def
test_initialValue
(
self
):
"check Parameter.initialValue"
p1
=
Parameter
(
1
,
0.25
)
self
.
assertEqual
(
0.25
,
p1
.
initialValue
())
self
.
assertEqual
(
"0.25"
,
p1
.
initialStr
())
px
=
Parameter
(
7
,
"=undefined"
)
self
.
assertRaises
(
ControlKeyError
,
px
.
initialValue
)
self
.
assertEqual
(
"=undefined:7"
,
px
.
initialStr
())
return
# End of class TestParameter
# ----------------------------------------------------------------------------
if
__name__
==
"__main__"
:
unittest
.
main
()
Back
|
FazBrowse Home
|
New Git URL