99@pytest .mark .parametrize (
1010 "wavelength, q, expected_tth" ,
1111 [
12- # Case 1: Allow empty arrays for q
13- # 1. Empty q values, no wavelength, return empty arrays
12+ # Test conversion of q to tth with valid values
13+ # C1. Empty q values
14+ # 1. No wavelength, expect empty arrays
1415 (None , np .empty ((0 )), np .empty ((0 ))),
15- # 2. Empty q values, wavelength specified, return empty arrays
16+ # 2. 4π wavelength, expect empty arrays
1617 (4 * np .pi , np .empty ((0 )), np .empty (0 )),
17- # Case 2: Allow wavelength to be missing.
18- # Valid q values, no wavelength, return index array
18+
19+ # C2. Non-empty q values
20+ # 2. No wavelength, expect value tth values
1921 (
2022 None ,
2123 np .array ([0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ]),
2224 np .array ([0 , 1 , 2 , 3 , 4 , 5 ]),
2325 ),
24- # Case 3: Correctly specified q and wavelength
25- # Expected tth values are 2*arcsin(q) in degrees
26+
27+ # C3: Both valid q and wavelength provided
28+ # 1. Expected tth values are 2*arcsin(q) in degrees
2629 (4 * np .pi , np .array ([0 , 1 / np .sqrt (2 ), 1.0 ]), np .array ([0 , 90.0 , 180.0 ])),
2730 ],
2831)
@@ -38,14 +41,15 @@ def test_q_to_tth(wavelength, q, expected_tth, wavelength_warning_msg):
3841
3942@pytest .mark .parametrize (
4043 "wavelength, q, expected_error_type" ,
41- [
42- # UC1: user specified invalid q values that result in tth > 180 degrees
44+ [
45+ # Test error messages in q to tth conversion with invalid Two theta values.
46+ # C1: Invalid q values that result in tth > 180 degrees
4347 (
4448 4 * np .pi ,
4549 np .array ([0.2 , 0.4 , 0.6 , 0.8 , 1 , 1.2 ]),
4650 ValueError ,
4751 ),
48- # UC2: user specified a wrong wavelength that result in tth > 180 degrees
52+ # C2: Wrong wavelength that results in tth > 180 degrees
4953 (
5054 100 ,
5155 np .array ([0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ]),
@@ -62,17 +66,17 @@ def test_q_to_tth_bad(wavelength, q, expected_error_type, invalid_q_or_d_or_wave
6266@pytest .mark .parametrize (
6367 "wavelength, tth, expected_q" ,
6468 [
65- # UC0: user specified empty tth values (without wavelength)
69+ # C0: Empty tth values (without wavelength)
6670 (None , np .array ([]), np .array ([])),
67- # UC1: user specified empty tth values (with wavelength)
71+ # C1: Empty tth values (with wavelength)
6872 (4 * np .pi , np .array ([]), np .array ([])),
69- # UC2: user specified valid tth values between 0-180 degrees (without wavelength)
73+ # C2: valid tth values between 0-180 degrees (without wavelength)
7074 (
7175 None ,
7276 np .array ([0 , 30 , 60 , 90 , 120 , 180 ]),
7377 np .array ([0 , 1 , 2 , 3 , 4 , 5 ]),
7478 ),
75- # UC3: user specified valid tth values between 0-180 degrees (with wavelength)
79+ # C3: valid tth values between 0-180 degrees (with wavelength)
7680 # expected q values are sin15, sin30, sin45, sin60, sin90
7781 (
7882 4 * np .pi ,
@@ -94,14 +98,14 @@ def test_tth_to_q(wavelength, tth, expected_q, wavelength_warning_msg):
9498@pytest .mark .parametrize (
9599 "wavelength, tth, expected_error_type, expected_error_msg" ,
96100 [
97- # UC0: user specified an invalid tth value of > 180 degrees (without wavelength)
101+ # C1: invalid tth value of > 180 degrees, no wavelength, expect two theta ValueError
98102 (
99103 None ,
100104 np .array ([0 , 30 , 60 , 90 , 120 , 181 ]),
101105 ValueError ,
102106 "Two theta exceeds 180 degrees. Please check the input values for errors." ,
103107 ),
104- # UC1: user specified an invalid tth value of > 180 degrees ( with wavelength)
108+ # C2: invalid tth value of > 180 degrees with wavelength, expect two theta ValueError
105109 (
106110 4 * np .pi ,
107111 np .array ([0 , 30 , 60 , 90 , 120 , 181 ]),
@@ -119,9 +123,9 @@ def test_tth_to_q_bad(wavelength, tth, expected_error_type, expected_error_msg):
119123 "q, expected_d, warning_expected" ,
120124 [
121125 # Test conversion of q to d with valid values
122- # Case 1 : empty q values, expect empty d values
126+ # C1 : empty q values, expect empty d values
123127 (np .array ([]), np .array ([]), False ),
124- # Case 2 :
128+ # C2 :
125129 # 1. valid q values, expect d values without warning
126130 (
127131 np .array ([0.1 , 1 * np .pi , 2 * np .pi , 3 * np .pi , 4 * np .pi , 5 * np .pi ]),
@@ -148,9 +152,9 @@ def test_q_to_d(q, expected_d, warning_expected):
148152@pytest .mark .parametrize (
149153 "d, expected_q, zero_divide_error_expected" ,
150154 [
151- # UC1 : User specified empty d values
155+ # C1 : User specified empty d values
152156 (np .array ([]), np .array ([]), False ),
153- # UC2 : User specified valid d values
157+ # C2 : User specified valid d values
154158 (
155159 np .array ([5 * np .pi , 4 * np .pi , 3 * np .pi , 2 * np .pi , np .pi , 0 ]),
156160 np .array ([0.4 , 0.5 , 0.66667 , 1 , 2 , np .inf ]),
@@ -171,13 +175,13 @@ def test_d_to_q(d, expected_q, zero_divide_error_expected):
171175 "wavelength, tth, expected_d, divide_by_zero_warning_expected" ,
172176 [
173177 # Test conversion of q to d with valid values
174- # Case 1 : empty tth values, no, expect empty d values
178+ # C1 : empty tth values, no, expect empty d values
175179 (None , np .array ([]), np .array ([]), False ),
176- # Case 2 : empty tth values, wavelength provided, expect empty d values
180+ # C2 : empty tth values, wavelength provided, expect empty d values
177181 (4 * np .pi , np .array ([]), np .array ([]), False ),
178- # Case 3 : User specified valid tth values between 0-180 degrees (without wavelength)
182+ # C3 : User specified valid tth values between 0-180 degrees (without wavelength)
179183 (None , np .array ([0 , 30 , 60 , 90 , 120 , 180 ]), np .array ([0 , 1 , 2 , 3 , 4 , 5 ]), False ),
180- # Case 4 : User specified valid tth values between 0-180 degrees (with wavelength)
184+ # C4 : User specified valid tth values between 0-180 degrees (with wavelength)
181185 (
182186 4 * np .pi ,
183187 np .array ([0 , 30.0 , 60.0 , 90.0 , 120.0 , 180.0 ]),
@@ -201,14 +205,14 @@ def test_tth_to_d(wavelength, tth, expected_d, divide_by_zero_warning_expected,
201205@pytest .mark .parametrize (
202206 "wavelength, tth, expected_error_type, expected_error_msg" ,
203207 [
204- # UC1 : user specified an invalid tth value of > 180 degrees (without wavelength)
208+ # C1 : user specified an invalid tth value of > 180 degrees (without wavelength)
205209 (
206210 None ,
207211 np .array ([0 , 30 , 60 , 90 , 120 , 181 ]),
208212 ValueError ,
209213 "Two theta exceeds 180 degrees. Please check the input values for errors." ,
210214 ),
211- # UC2 : user specified an invalid tth value of > 180 degrees (with wavelength)
215+ # C2 : user specified an invalid tth value of > 180 degrees (with wavelength)
212216 (
213217 4 * np .pi ,
214218 np .array ([0 , 30 , 60 , 90 , 120 , 181 ]),
@@ -225,13 +229,13 @@ def test_tth_to_d_invalid(wavelength, tth, expected_error_type, expected_error_m
225229@pytest .mark .parametrize (
226230 "wavelength, d, expected_tth, divide_by_zero_warning_expected" ,
227231 [
228- # UC1 : Empty d values, no wavelength, return empty arrays
232+ # C1 : Empty d values, no wavelength, return empty arrays
229233 (None , np .empty ((0 )), np .empty ((0 )), False ),
230- # UC2 : Empty d values, wavelength specified, return empty arrays
234+ # C2 : Empty d values, wavelength specified, return empty arrays
231235 (4 * np .pi , np .empty ((0 )), np .empty (0 ), False ),
232- # UC3 : User specified valid d values, no wavelength, return empty arrays
236+ # C3 : User specified valid d values, no wavelength, return empty arrays
233237 (None , np .array ([1 , 0.8 , 0.6 , 0.4 , 0.2 , 0 ]), np .array ([0 , 1 , 2 , 3 , 4 , 5 ]), True ),
234- # UC4 : User specified valid d values (with wavelength)
238+ # C4 : User specified valid d values (with wavelength)
235239 (
236240 4 * np .pi ,
237241 np .array ([4 * np .pi , 4 / np .sqrt (2 ) * np .pi , 4 / np .sqrt (3 ) * np .pi ]),
@@ -257,9 +261,9 @@ def test_d_to_tth(wavelength, d, expected_tth, divide_by_zero_warning_expected,
257261@pytest .mark .parametrize (
258262 "wavelength, d, expected_error_type" ,
259263 [
260- # UC1 : user specified invalid d values that result in tth > 180 degrees
264+ # C1 : user specified invalid d values that result in tth > 180 degrees
261265 (4 * np .pi , np .array ([1.2 , 1 , 0.8 , 0.6 , 0.4 , 0.2 ]), ValueError ),
262- # UC2 : user specified a wrong wavelength that result in tth > 180 degrees
266+ # C2 : user specified a wrong wavelength that result in tth > 180 degrees
263267 (100 , np .array ([1.2 , 1 , 0.8 , 0.6 , 0.4 , 0.2 ]), ValueError ),
264268 ],
265269)
0 commit comments