Skip to content

Commit a53461f

Browse files
edit warning msg for wavelength, change index error to runtime error
1 parent 3efde28 commit a53461f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/diffpy/utils/scattering_objects/test_diffraction_objects.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,10 @@ def _test_valid_diffraction_objects(actual_diffraction_object, function, expecte
241241
assert str(warn_record[0].message) == (
242242
"INFO: no wavelength has been specified. You can continue "
243243
"to use the DiffractionObject but some of its powerful features "
244-
"will not be available. To specify a wavelength, you can use "
245-
"DiffractionObject(wavelength=0.71)."
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."
246248
)
247249
actual_array = getattr(actual_diffraction_object, function)()
248250
return np.allclose(actual_array, expected_array)
@@ -289,7 +291,7 @@ def test_q_to_tth(inputs, expected):
289291
[
290292
ValueError,
291293
"The supplied q-array and wavelength will result in an impossible two-theta. "
292-
"Please check these values and re-instantiate the DiffractionObject.",
294+
"Please check these values and re-instantiate the DiffractionObject with correct values.",
293295
],
294296
),
295297
# UC2: user specified a wrong wavelength that result in tth > 180 degrees
@@ -304,12 +306,12 @@ def test_q_to_tth(inputs, expected):
304306
# UC3: user specified a q array that does not match the length of intensity array (without wavelength)
305307
(
306308
[None, [0, 0.2, 0.4, 0.6, 0.8, 1], [1, 2, 3, 4, 5]],
307-
[IndexError, "Please ensure q array and intensity array are the same length."],
309+
[RuntimeError, "Please ensure q array and intensity array are the same length."],
308310
),
309311
# UC4: user specified a q array that does not match the length of intensity array (with wavelength)
310312
(
311313
[4 * np.pi, [0, 0.2, 0.4, 0.6, 0.8, 1], [1, 2, 3, 4, 5]],
312-
[IndexError, "Please ensure q array and intensity array are the same length."],
314+
[RuntimeError, "Please ensure q array and intensity array are the same length."],
313315
),
314316
# UC5: user specified a non-numeric value in q array (without wavelength)
315317
(
@@ -379,12 +381,12 @@ def test_tth_to_q(inputs, expected):
379381
# UC3: user specified a two theta array that does not match the length of intensity array (without wavelength)
380382
(
381383
[None, [0, 30, 60, 90, 120], [1, 2, 3, 4, 5, 6]],
382-
[IndexError, "Please ensure two theta array and intensity array are the same length."],
384+
[RuntimeError, "Please ensure two theta array and intensity array are the same length."],
383385
),
384386
# UC4: user specified a two theta array that does not match the length of intensity array (with wavelength)
385387
(
386388
[4 * np.pi, [0, 30, 60, 90, 120], [1, 2, 3, 4, 5, 6]],
387-
[IndexError, "Please ensure two theta array and intensity array are the same length."],
389+
[RuntimeError, "Please ensure two theta array and intensity array are the same length."],
388390
),
389391
# UC5: user specified a non-numeric value in two theta array (without wavelength)
390392
(

0 commit comments

Comments
 (0)