@@ -190,29 +190,11 @@ def test_init_invalid_xtype():
190190@pytest .mark .parametrize (
191191 "org_do_args, target_do_args, scale_inputs, expected" ,
192192 [
193- # Test whether scale_to() scales to the expected values
194- ( # C1: Same x-array and y-array with 2.1 offset, expect yarray shifted by 2.1 offset
195- {
196- "xarray" : np .array ([10 , 15 , 25 , 30 , 60 , 140 ]),
197- "yarray" : np .array ([2 , 3 , 4 , 5 , 6 , 7 ]),
198- "xtype" : "tth" ,
199- "wavelength" : 2 * np .pi ,
200- },
201- {
202- "xarray" : np .array ([10 , 15 , 25 , 30 , 60 , 140 ]),
203- "yarray" : np .array ([2 , 3 , 4 , 5 , 6 , 7 ]),
204- "xtype" : "tth" ,
205- "wavelength" : 2 * np .pi ,
206- },
207- {
208- "q" : None ,
209- "tth" : 60 ,
210- "d" : None ,
211- "offset" : 2.1 ,
212- },
213- {"xtype" : "tth" , "yarray" : np .array ([4.1 , 5.1 , 6.1 , 7.1 , 8.1 , 9.1 ])},
214- ),
215- ( # C2: Same length x-arrays with exact x-value match
193+ # Test whether the original y-array is scaled as expected
194+ ( # C1: Same x-arrays
195+ # x-value has exact matches at tth=60 (y=60) and tth=60 (y=6),
196+ # for original and target diffraction objects,
197+ # expect original y-array to multiply by 6/60=1/10
216198 {
217199 "xarray" : np .array ([10 , 15 , 25 , 30 , 60 , 140 ]),
218200 "yarray" : np .array ([10 , 20 , 25 , 30 , 60 , 100 ]),
@@ -233,7 +215,10 @@ def test_init_invalid_xtype():
233215 },
234216 {"xtype" : "tth" , "yarray" : np .array ([1 , 2 , 2.5 , 3 , 6 , 10 ])},
235217 ),
236- ( # C3: Same length x-arrays with approximate x-value match
218+ ( # C2: Different x-arrays with same length,
219+ # x-value has closest match at q=0.12 (y=10) and q=0.14 (y=1)
220+ # for original and target diffraction objects,
221+ # expect original y-array to multiply by 1/10
237222 {
238223 "xarray" : np .array ([0.12 , 0.24 , 0.31 , 0.4 ]),
239224 "yarray" : np .array ([10 , 20 , 40 , 60 ]),
@@ -254,7 +239,10 @@ def test_init_invalid_xtype():
254239 },
255240 {"xtype" : "q" , "yarray" : np .array ([1 , 2 , 4 , 6 ])},
256241 ),
257- ( # C4: Different x-array lengths with approximate x-value match
242+ ( # C3: Different x-array lengths
243+ # x-value has closest matches at tth=61 (y=50) and tth=62 (y=5),
244+ # for original and target diffraction objects,
245+ # expect original y-array to multiply by 5/50=1/10
258246 {
259247 "xarray" : np .array ([10 , 25 , 30.1 , 40.2 , 61 , 120 , 140 ]),
260248 "yarray" : np .array ([10 , 20 , 30 , 40 , 50 , 60 , 100 ]),
@@ -273,9 +261,29 @@ def test_init_invalid_xtype():
273261 "d" : None ,
274262 "offset" : 0 ,
275263 },
276- # C5: Scaling factor is calculated at index = 4 (tth=61) for self and index = 5 for target (tth=62)
277264 {"xtype" : "tth" , "yarray" : np .array ([1 , 2 , 3 , 4 , 5 , 6 , 10 ])},
278265 ),
266+ ( # C4: Same x-array and y-array with 2.1 offset, expect y-array to shift up by 2.1
267+ {
268+ "xarray" : np .array ([10 , 15 , 25 , 30 , 60 , 140 ]),
269+ "yarray" : np .array ([2 , 3 , 4 , 5 , 6 , 7 ]),
270+ "xtype" : "tth" ,
271+ "wavelength" : 2 * np .pi ,
272+ },
273+ {
274+ "xarray" : np .array ([10 , 15 , 25 , 30 , 60 , 140 ]),
275+ "yarray" : np .array ([2 , 3 , 4 , 5 , 6 , 7 ]),
276+ "xtype" : "tth" ,
277+ "wavelength" : 2 * np .pi ,
278+ },
279+ {
280+ "q" : None ,
281+ "tth" : 60 ,
282+ "d" : None ,
283+ "offset" : 2.1 ,
284+ },
285+ {"xtype" : "tth" , "yarray" : np .array ([4.1 , 5.1 , 6.1 , 7.1 , 8.1 , 9.1 ])},
286+ ),
279287 ],
280288)
281289def test_scale_to (org_do_args , target_do_args , scale_inputs , expected ):
0 commit comments