-
Notifications
You must be signed in to change notification settings - Fork 21
1) Capture no wavelength UserWarning for test_q_to_thh method 2) discuss passing variables to @pytest.mark.parametrize
#225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
781e358
7ac21a3
792ce17
4d0f762
8c891db
cce5716
6bb822f
d176b6b
69aa7c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,24 +5,31 @@ | |
|
|
||
| params_q_to_tth = [ | ||
| # UC1: Empty q values, no wavelength, return empty arrays | ||
| ([None, np.empty((0))], np.empty((0))), | ||
| # UC2: Empty q values, wavelength specified, return empty arrays | ||
| ([4 * np.pi, np.empty((0))], np.empty(0)), | ||
| (None, np.empty((0)), np.empty((0))), | ||
| # # UC2: Empty q values, wavelength specified, return empty arrays | ||
| (4 * np.pi, np.empty((0)), np.empty(0)), | ||
| # UC3: User specified valid q values, no wavelength, return empty arrays | ||
| ( | ||
| [None, np.array([0, 0.2, 0.4, 0.6, 0.8, 1])], | ||
| None, | ||
| np.array([0, 0.2, 0.4, 0.6, 0.8, 1]), | ||
| np.array([0, 1, 2, 3, 4, 5]), | ||
| ), | ||
| # UC4: User specified valid q values (with wavelength) | ||
| # expected tth values are 2*arcsin(q) in degrees | ||
| ([4 * np.pi, np.array([0, 1 / np.sqrt(2), 1.0])], np.array([0, 90.0, 180.0])), | ||
| (4 * np.pi, np.array([0, 1 / np.sqrt(2), 1.0]), np.array([0, 90.0, 180.0])), | ||
| ] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("inputs, expected", params_q_to_tth) | ||
| def test_q_to_tth(inputs, expected): | ||
| actual = q_to_tth(inputs[1], inputs[0]) | ||
| assert np.allclose(expected, actual) | ||
| @pytest.mark.parametrize("wavelength, q, expected_tth", params_q_to_tth) | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def test_q_to_tth(wavelength, q, expected_tth): | ||
|
|
||
| if wavelength is None: | ||
| with pytest.warns(UserWarning, match="INFO: no wavelength has been specified"): | ||
|
||
| actual_tth = q_to_tth(q, wavelength) | ||
| else: | ||
| actual_tth = q_to_tth(q, wavelength) | ||
|
|
||
| assert np.allclose(expected_tth, actual_tth) | ||
|
|
||
|
|
||
| params_q_to_tth_bad = [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.