5
5
6
6
params_q_to_tth = [
7
7
# UC1: Empty q values, no wavelength, return empty arrays
8
- ([None , np .empty ((2 , 0 ))], np .empty ((2 , 0 ))),
8
+ ([None , np .empty ((1 , ))], np .empty ((1 , ))),
9
9
# UC2: Empty q values, wavelength specified, return empty arrays
10
- ([4 * np .pi , np .empty ((2 , 0 ))], np .empty ((2 , 0 ))),
10
+ ([4 * np .pi , np .empty ((1 , ))], np .empty ((1 , ))),
11
11
# UC3: User specified valid q values, no wavelength, return empty arrays
12
12
(
13
- [None , np .array ([[ 0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ])],
14
- np .array ([[ 0 , 1 , 2 , 3 , 4 , 5 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ]),
13
+ [None , np .array ([0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ])],
14
+ np .array ([0 , 1 , 2 , 3 , 4 , 5 ]),
15
15
),
16
16
# UC4: User specified valid q values (with wavelength)
17
17
# expected tth values are 2*arcsin(q) in degrees
18
- ([4 * np .pi , np .array ([[ 0 , 1 / np .sqrt (2 ), 1.0 ], [ 1 , 2 , 3 ]] )], np .array ([[ 0 , 90.0 , 180.0 ], [ 1 , 2 , 3 ] ])),
18
+ ([4 * np .pi , np .array ([0 , 1 / np .sqrt (2 ), 1.0 ])], np .array ([0 , 90.0 , 180.0 ])),
19
19
]
20
20
21
21
22
22
@pytest .mark .parametrize ("inputs, expected" , params_q_to_tth )
23
23
def test_q_to_tth (inputs , expected ):
24
24
actual = q_to_tth (inputs [1 ], inputs [0 ])
25
- assert np .allclose (expected [0 ], actual [0 ])
26
- assert np .allclose (expected [1 ], actual [1 ])
25
+ assert np .allclose (expected , actual )
27
26
28
27
29
28
params_q_to_tth_bad = [
30
29
# UC1: user specified invalid q values that result in tth > 180 degrees
31
30
(
32
- [4 * np .pi , np .array ([[ 0.2 , 0.4 , 0.6 , 0.8 , 1 , 1.2 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ])],
31
+ [4 * np .pi , np .array ([0.2 , 0.4 , 0.6 , 0.8 , 1 , 1.2 ])],
33
32
[
34
33
ValueError ,
35
34
"The supplied q-array and wavelength will result in an impossible two-theta. "
@@ -38,7 +37,7 @@ def test_q_to_tth(inputs, expected):
38
37
),
39
38
# UC2: user specified a wrong wavelength that result in tth > 180 degrees
40
39
(
41
- [100 , np .array ([[ 0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ])],
40
+ [100 , np .array ([0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ])],
42
41
[
43
42
ValueError ,
44
43
"The supplied q-array and wavelength will result in an impossible two-theta. "
@@ -56,19 +55,19 @@ def test_q_to_tth_bad(inputs, expected):
56
55
57
56
params_tth_to_q = [
58
57
# UC0: User specified empty tth values (without wavelength)
59
- ([None , np .array ([[], []] )], np .array ([[], [] ])),
58
+ ([None , np .array ([] )], np .array ([])),
60
59
# UC1: User specified empty tth values (with wavelength)
61
- ([4 * np .pi , np .array ([[], []] )], np .array ([[], [] ])),
60
+ ([4 * np .pi , np .array ([] )], np .array ([])),
62
61
# UC2: User specified valid tth values between 0-180 degrees (without wavelength)
63
62
(
64
- [None , np .array ([[ 0 , 30 , 60 , 90 , 120 , 180 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ])],
65
- np .array ([[ 0 , 1 , 2 , 3 , 4 , 5 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ]),
63
+ [None , np .array ([0 , 30 , 60 , 90 , 120 , 180 ])],
64
+ np .array ([0 , 1 , 2 , 3 , 4 , 5 ]),
66
65
),
67
66
# UC3: User specified valid tth values between 0-180 degrees (with wavelength)
68
67
# expected q vales are sin15, sin30, sin45, sin60, sin90
69
68
(
70
- [4 * np .pi , np .array ([[ 0 , 30.0 , 60.0 , 90.0 , 120.0 , 180.0 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ])],
71
- np .array ([[ 0 , 0.258819 , 0.5 , 0.707107 , 0.866025 , 1 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ]),
69
+ [4 * np .pi , np .array ([0 , 30.0 , 60.0 , 90.0 , 120.0 , 180.0 ])],
70
+ np .array ([0 , 0.258819 , 0.5 , 0.707107 , 0.866025 , 1 ]),
72
71
),
73
72
]
74
73
@@ -82,12 +81,12 @@ def test_tth_to_q(inputs, expected):
82
81
params_tth_to_q_bad = [
83
82
# UC0: user specified an invalid tth value of > 180 degrees (without wavelength)
84
83
(
85
- [None , np .array ([[ 0 , 30 , 60 , 90 , 120 , 181 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ])],
84
+ [None , np .array ([0 , 30 , 60 , 90 , 120 , 181 ])],
86
85
[ValueError , "Two theta exceeds 180 degrees. Please check the input values for errors." ],
87
86
),
88
87
# UC1: user specified an invalid tth value of > 180 degrees (with wavelength)
89
88
(
90
- [4 * np .pi , np .array ([[ 0 , 30 , 60 , 90 , 120 , 181 ], [ 1 , 2 , 3 , 4 , 5 , 6 ] ])],
89
+ [4 * np .pi , np .array ([0 , 30 , 60 , 90 , 120 , 181 ])],
91
90
[ValueError , "Two theta exceeds 180 degrees. Please check the input values for errors." ],
92
91
),
93
92
]
0 commit comments