@@ -284,23 +284,7 @@ def test_init_invalid_xtype():
284284 },
285285 {"xtype" : "tth" , "yarray" : np .array ([4.1 , 5.1 , 6.1 , 7.1 , 8.1 , 9.1 ])},
286286 ),
287- ],
288- )
289- def test_scale_to (org_do_args , target_do_args , scale_inputs , expected ):
290- original_do = DiffractionObject (** org_do_args )
291- target_do = DiffractionObject (** target_do_args )
292- scaled_do = original_do .scale_to (
293- target_do , q = scale_inputs ["q" ], tth = scale_inputs ["tth" ], d = scale_inputs ["d" ], offset = scale_inputs ["offset" ]
294- )
295- # Check the intensity data is the same as expected
296- assert np .allclose (scaled_do .on_xtype (expected ["xtype" ])[1 ], expected ["yarray" ])
297-
298-
299- @pytest .mark .parametrize (
300- "org_do_args, target_do_args, scale_inputs" ,
301- [
302- # Test expected errors produced from scale_to() with invalid inputs
303- ( # C1: none of q, tth, d, provided, expect ValueError
287+ ( # C5: none of q, tth, d, provided, expect to scale on the maximal x-arrays
304288 {
305289 "xarray" : np .array ([0.1 , 0.2 , 0.3 ]),
306290 "yarray" : np .array ([1 , 2 , 3 ]),
@@ -319,8 +303,25 @@ def test_scale_to(org_do_args, target_do_args, scale_inputs, expected):
319303 "d" : None ,
320304 "offset" : 0 ,
321305 },
306+ {"xtype" : "q" , "yarray" : np .array ([10 , 20 , 30 ])},
322307 ),
323- ( # C2: tth and d both provided, expect ValueErrort
308+ ],
309+ )
310+ def test_scale_to (org_do_args , target_do_args , scale_inputs , expected ):
311+ original_do = DiffractionObject (** org_do_args )
312+ target_do = DiffractionObject (** target_do_args )
313+ scaled_do = original_do .scale_to (
314+ target_do , q = scale_inputs ["q" ], tth = scale_inputs ["tth" ], d = scale_inputs ["d" ], offset = scale_inputs ["offset" ]
315+ )
316+ # Check the intensity data is the same as expected
317+ assert np .allclose (scaled_do .on_xtype (expected ["xtype" ])[1 ], expected ["yarray" ])
318+
319+
320+ @pytest .mark .parametrize (
321+ "org_do_args, target_do_args, scale_inputs" ,
322+ [
323+ # Test expected errors produced from scale_to() with invalid inputs
324+ ( # C2: tth and d both provided, expect ValueError
324325 {
325326 "xarray" : np .array ([10 , 25 , 30.1 , 40.2 , 61 , 120 , 140 ]),
326327 "yarray" : np .array ([10 , 20 , 30 , 40 , 50 , 60 , 100 ]),
@@ -346,7 +347,9 @@ def test_scale_to_bad(org_do_args, target_do_args, scale_inputs):
346347 original_do = DiffractionObject (** org_do_args )
347348 target_do = DiffractionObject (** target_do_args )
348349 with pytest .raises (
349- ValueError , match = "You must specify exactly one of 'q', 'tth', or 'd'. Please rerun specifying only one."
350+ ValueError ,
351+ match = "You must specify none or exactly one of 'q', 'tth', or 'd'. "
352+ "Please provide either none or one value." ,
350353 ):
351354 original_do .scale_to (
352355 target_do ,
0 commit comments