55
66params_q_to_tth = [
77 # 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 , ))),
99 # 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 , ))),
1111 # UC3: User specified valid q values, no wavelength, return empty arrays
1212 (
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 ]),
1515 ),
1616 # UC4: User specified valid q values (with wavelength)
1717 # 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 ])),
1919]
2020
2121
2222@pytest .mark .parametrize ("inputs, expected" , params_q_to_tth )
2323def test_q_to_tth (inputs , expected ):
2424 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 )
2726
2827
2928params_q_to_tth_bad = [
3029 # UC1: user specified invalid q values that result in tth > 180 degrees
3130 (
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 ])],
3332 [
3433 ValueError ,
3534 "The supplied q-array and wavelength will result in an impossible two-theta. "
@@ -38,7 +37,7 @@ def test_q_to_tth(inputs, expected):
3837 ),
3938 # UC2: user specified a wrong wavelength that result in tth > 180 degrees
4039 (
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 ])],
4241 [
4342 ValueError ,
4443 "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):
5655
5756params_tth_to_q = [
5857 # UC0: User specified empty tth values (without wavelength)
59- ([None , np .array ([[], []] )], np .array ([[], [] ])),
58+ ([None , np .array ([] )], np .array ([])),
6059 # UC1: User specified empty tth values (with wavelength)
61- ([4 * np .pi , np .array ([[], []] )], np .array ([[], [] ])),
60+ ([4 * np .pi , np .array ([] )], np .array ([])),
6261 # UC2: User specified valid tth values between 0-180 degrees (without wavelength)
6362 (
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 ]),
6665 ),
6766 # UC3: User specified valid tth values between 0-180 degrees (with wavelength)
6867 # expected q vales are sin15, sin30, sin45, sin60, sin90
6968 (
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 ]),
7271 ),
7372]
7473
@@ -82,12 +81,12 @@ def test_tth_to_q(inputs, expected):
8281params_tth_to_q_bad = [
8382 # UC0: user specified an invalid tth value of > 180 degrees (without wavelength)
8483 (
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 ])],
8685 [ValueError , "Two theta exceeds 180 degrees. Please check the input values for errors." ],
8786 ),
8887 # UC1: user specified an invalid tth value of > 180 degrees (with wavelength)
8988 (
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 ])],
9190 [ValueError , "Two theta exceeds 180 degrees. Please check the input values for errors." ],
9291 ),
9392]
0 commit comments