44import pytest
55from freezegun import freeze_time
66
7- from diffpy .utils .scattering_objects .diffraction_objects import DiffractionObject
7+ from diffpy .utils .scattering_objects .diffraction_objects import DiffractionObject , wavelength_warning_emsg
88
99params = [
1010 ( # Default
@@ -238,35 +238,18 @@ def _test_valid_diffraction_objects(actual_diffraction_object, function, expecte
238238 if actual_diffraction_object .wavelength is None :
239239 with pytest .warns (UserWarning ) as warn_record :
240240 getattr (actual_diffraction_object , function )()
241- assert str (warn_record [0 ].message ) == (
242- "INFO: no wavelength has been specified. You can continue "
243- "to use the DiffractionObject but some of its powerful features "
244- "will not be available. To specify a wavelength, set "
245- "diffraction_object.wavelength = [number], "
246- "where diffraction_object is the variable name of you Diffraction Object, "
247- "and number is the wavelength in angstroms."
248- )
241+ assert str (warn_record [0 ].message ) == wavelength_warning_emsg
249242 actual_array = getattr (actual_diffraction_object , function )()
250243 return np .allclose (actual_array , expected_array )
251244
252245
253246params_q_to_tth = [
254247 # UC1: User specified empty q values (without wavelength)
255- (
256- [None , [], []],
257- [[]],
258- ),
248+ ([None , [], []], [[]]),
259249 # UC2: User specified empty q values (with wavelength)
260- (
261- [4 * np .pi , [], []],
262- [[]],
263- ),
250+ ([4 * np .pi , [], []], [[]]),
264251 # UC3: User specified valid q values (without wavelength)
265- # expected tth values are 2*arcsin(q) in degrees
266- (
267- [None , [0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ], [1 , 2 , 3 , 4 , 5 , 6 ]],
268- [[]],
269- ),
252+ ([None , [0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ], [1 , 2 , 3 , 4 , 5 , 6 ]], [[]]),
270253 # UC4: User specified valid q values (with wavelength)
271254 # expected tth values are 2*arcsin(q) in degrees
272255 (
@@ -300,18 +283,18 @@ def test_q_to_tth(inputs, expected):
300283 [
301284 ValueError ,
302285 "The supplied q-array and wavelength will result in an impossible two-theta. "
303- "Please check these values and re-instantiate the DiffractionObject." ,
286+ "Please check these values and re-instantiate the DiffractionObject with correct values ." ,
304287 ],
305288 ),
306289 # UC3: user specified a q array that does not match the length of intensity array (without wavelength)
307290 (
308291 [None , [0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ], [1 , 2 , 3 , 4 , 5 ]],
309- [RuntimeError , "Please ensure q array and intensity array are the same length." ],
292+ [RuntimeError , "Please ensure q array and intensity array are of the same length." ],
310293 ),
311294 # UC4: user specified a q array that does not match the length of intensity array (with wavelength)
312295 (
313296 [4 * np .pi , [0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ], [1 , 2 , 3 , 4 , 5 ]],
314- [RuntimeError , "Please ensure q array and intensity array are the same length." ],
297+ [RuntimeError , "Please ensure q array and intensity array are of the same length." ],
315298 ),
316299 # UC5: user specified a non-numeric value in q array (without wavelength)
317300 (
@@ -336,26 +319,17 @@ def test_q_to_tth_bad(inputs, expected):
336319
337320params_tth_to_q = [
338321 # UC1: User specified empty tth values (without wavelength)
339- (
340- [None , [], []],
341- [[]],
342- ),
322+ ([None , [], []], [[]]),
343323 # UC2: User specified empty tth values (with wavelength)
344- (
345- [4 * np .pi , [], []],
346- [[]],
347- ),
324+ ([4 * np .pi , [], []], [[]]),
348325 # UC3: User specified valid tth values between 0-180 degrees (without wavelength)
349326 (
350327 [None , [0 , 30 , 60 , 90 , 120 , 180 ], [1 , 2 , 3 , 4 , 5 , 6 ]],
351328 [[]],
352329 ),
353330 # UC4: User specified valid tth values between 0-180 degrees (with wavelength)
354331 # expected q vales are sin15, sin30, sin45, sin60, sin90
355- (
356- [4 * np .pi , [0 , 30 , 60 , 90 , 120 , 180 ], [1 , 2 , 3 , 4 , 5 , 6 ]],
357- [[0 , 0.258819 , 0.5 , 0.707107 , 0.866025 , 1 ]],
358- ),
332+ ([4 * np .pi , [0 , 30 , 60 , 90 , 120 , 180 ], [1 , 2 , 3 , 4 , 5 , 6 ]], [[0 , 0.258819 , 0.5 , 0.707107 , 0.866025 , 1 ]]),
359333]
360334
361335
@@ -381,12 +355,12 @@ def test_tth_to_q(inputs, expected):
381355 # UC3: user specified a two theta array that does not match the length of intensity array (without wavelength)
382356 (
383357 [None , [0 , 30 , 60 , 90 , 120 ], [1 , 2 , 3 , 4 , 5 , 6 ]],
384- [RuntimeError , "Please ensure two theta array and intensity array are the same length." ],
358+ [RuntimeError , "Please ensure two theta array and intensity array are of the same length." ],
385359 ),
386360 # UC4: user specified a two theta array that does not match the length of intensity array (with wavelength)
387361 (
388362 [4 * np .pi , [0 , 30 , 60 , 90 , 120 ], [1 , 2 , 3 , 4 , 5 , 6 ]],
389- [RuntimeError , "Please ensure two theta array and intensity array are the same length." ],
363+ [RuntimeError , "Please ensure two theta array and intensity array are of the same length." ],
390364 ),
391365 # UC5: user specified a non-numeric value in two theta array (without wavelength)
392366 (
0 commit comments