@@ -218,7 +218,7 @@ def _test_valid_diffraction_objects(actual_diffraction_object, function, expecte
218218 # UC2: target value lies in the array, returns the (first) closest index
219219 ([4 * np .pi , np .array ([30 , 60 ]), np .array ([1 , 2 ]), "tth" , "tth" , 45 ], [0 ]),
220220 ([4 * np .pi , np .array ([30 , 60 ]), np .array ([1 , 2 ]), "tth" , "q" , 0.25 ], [0 ]),
221- # UC3: target value out of the range but within reasonable distance , returns the closest index
221+ # UC3: target value out of the range, returns the closest index
222222 ([4 * np .pi , np .array ([0.25 , 0.5 , 0.71 ]), np .array ([1 , 2 , 3 ]), "q" , "q" , 0.1 ], [0 ]),
223223 ([4 * np .pi , np .array ([30 , 60 ]), np .array ([1 , 2 ]), "tth" , "tth" , 63 ], [1 ]),
224224]
@@ -231,46 +231,10 @@ def test_get_array_index(inputs, expected):
231231 assert actual == expected [0 ]
232232
233233
234- params_index_bad = [
235- # UC0: empty array
236- (
237- [2 * np .pi , np .array ([]), np .array ([]), "tth" , "tth" , 30 ],
238- [ValueError , "The 'tth' array is empty. Please ensure it is initialized and the correct xtype is used." ],
239- ),
240- # UC1: empty array (because of invalid xtype)
241- (
242- [2 * np .pi , np .array ([30 , 60 ]), np .array ([1 , 2 ]), "tth" , "invalid" , 30 ],
243- [
244- ValueError ,
245- "The 'invalid' array is empty. Please ensure it is initialized and the correct xtype is used." ,
246- ],
247- ),
248- # UC3: value is too far from any element in the array
249- (
250- [2 * np .pi , np .array ([30 , 60 , 90 ]), np .array ([1 , 2 , 3 ]), "tth" , "tth" , 140 ],
251- [
252- IndexError ,
253- "The value 140 is too far from any value in the 'tth' array. "
254- "Please check if you have specified the correct xtype." ,
255- ],
256- ),
257- # UC4: value is too far from any element in the array (because of wrong xtype)
258- (
259- [2 * np .pi , np .array ([30 , 60 , 90 ]), np .array ([1 , 2 , 3 ]), "tth" , "q" , 30 ],
260- [
261- IndexError ,
262- "The value 30 is too far from any value in the 'q' array. "
263- "Please check if you have specified the correct xtype." ,
264- ],
265- ),
266- ]
267-
268-
269- @pytest .mark .parametrize ("inputs, expected" , params_index_bad )
270- def test_get_array_index_bad (inputs , expected ):
271- test = DiffractionObject (wavelength = inputs [0 ], xarray = inputs [1 ], yarray = inputs [2 ], xtype = inputs [3 ])
272- with pytest .raises (expected [0 ], match = re .escape (expected [1 ])):
273- test .get_array_index (value = inputs [5 ], xtype = inputs [4 ])
234+ def test_get_array_index_bad ():
235+ test = DiffractionObject (wavelength = 2 * np .pi , xarray = np .array ([]), yarray = np .array ([]), xtype = "tth" )
236+ with pytest .raises (ValueError , match = re .escape ("The 'tth' array is empty. Please ensure it is initialized." )):
237+ test .get_array_index (value = 30 )
274238
275239
276240def test_dump (tmp_path , mocker ):
0 commit comments