-
Notifications
You must be signed in to change notification settings - Fork 21
Continue refactor test functions, replace UC
to C
in test_transforms.py
#266
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 404 402 -2
=========================================
- Hits 404 402 -2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the group, do we want to call it "C" instead of "Case"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think either can work
tests/test_transforms.py
Outdated
( | ||
None, | ||
np.array([0, 30, 60, 90, 120, 180]), | ||
np.array([0, 1, 2, 3, 4, 5]), | ||
), | ||
# UC3: user specified valid tth values between 0-180 degrees (with wavelength) | ||
# C3: valid tth values between 0-180 degrees (with wavelength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to call it UC
right? Since this is testing actual_q = tth_to_q(tth, wavelength)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We basically never want to see UCs in tests. UCs are enumerated lists of actions that describe user behavior when using an app.
tests/test_transforms.py
Outdated
@@ -94,14 +96,14 @@ def test_tth_to_q(wavelength, tth, expected_q, wavelength_warning_msg): | |||
@pytest.mark.parametrize( | |||
"wavelength, tth, expected_error_type, expected_error_msg", | |||
[ | |||
# UC0: user specified an invalid tth value of > 180 degrees (without wavelength) | |||
# C1: invalid tth value of > 180 degrees, no wavelength, expect two theta ValueError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above - testing tth_to_q(tth, wavelength)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, no UC
tests/test_transforms.py
Outdated
@@ -171,13 +173,13 @@ def test_d_to_q(d, expected_q, zero_divide_error_expected): | |||
"wavelength, tth, expected_d, divide_by_zero_warning_expected", | |||
[ | |||
# Test conversion of q to d with valid values | |||
# Case 1: empty tth values, no, expect empty d values | |||
# C1: empty tth values, no, expect empty d values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment - testing tth_to_d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either is fine
) | ||
|
||
|
||
params_index = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just moving params_index
under @pytest.mark.parametrize
@@ -406,7 +411,7 @@ def test_dump(tmp_path, mocker): | |||
@pytest.mark.parametrize( | |||
"do_init_args, expected_do_dict, divide_by_zero_warning_expected", | |||
[ | |||
( # instantiate just array attributes | |||
( # Instantiate just array attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick PEP8 standard, starting each comment with a cap letter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's use that convention. For the test cases I don't mind if they are full sentences or not tbh as long as the intent is clear.
# 2. Empty q values, wavelength specified, return empty arrays | ||
# Test conversion of q to tth with valid values | ||
# C1: Allow empty array q to compute tth with or without wavelength | ||
# 1. Wavelength provided, expect empty array of tth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the word expect
is better than return
since expect can be used for warnings too.
Would you have any further feedback on this refactored version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flow is like..
"The overall goal is toTest conversion of q to tth with valid values
. For the first case, we want to see if it Allows empty array q to compute tth with or without wavelength
. Then, for the first case of Wavelength provided, expect empty array of tth
. For the second case of No wavelength provided
, still expect an empty tth but hey you will also get a warning!"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your version looks great here
Very clear
@sbillinge ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see inline. It looks great. I will go ahead and merge.
@pytest.mark.parametrize( | ||
"org_do_args, target_do_args, scale_inputs", | ||
[ | ||
# UC1: User did not specify anything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UC -> C. Also these comments don't seem to correspond to the tests. Not sure what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I read above... You will do these on separate PRs, sorry!
tests/test_transforms.py
Outdated
( | ||
None, | ||
np.array([0, 30, 60, 90, 120, 180]), | ||
np.array([0, 1, 2, 3, 4, 5]), | ||
), | ||
# UC3: user specified valid tth values between 0-180 degrees (with wavelength) | ||
# C3: valid tth values between 0-180 degrees (with wavelength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We basically never want to see UCs in tests. UCs are enumerated lists of actions that describe user behavior when using an app.
tests/test_transforms.py
Outdated
@@ -94,14 +96,14 @@ def test_tth_to_q(wavelength, tth, expected_q, wavelength_warning_msg): | |||
@pytest.mark.parametrize( | |||
"wavelength, tth, expected_error_type, expected_error_msg", | |||
[ | |||
# UC0: user specified an invalid tth value of > 180 degrees (without wavelength) | |||
# C1: invalid tth value of > 180 degrees, no wavelength, expect two theta ValueError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, no UC
tests/test_transforms.py
Outdated
@@ -171,13 +173,13 @@ def test_d_to_q(d, expected_q, zero_divide_error_expected): | |||
"wavelength, tth, expected_d, divide_by_zero_warning_expected", | |||
[ | |||
# Test conversion of q to d with valid values | |||
# Case 1: empty tth values, no, expect empty d values | |||
# C1: empty tth values, no, expect empty d values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either is fine
@@ -406,7 +411,7 @@ def test_dump(tmp_path, mocker): | |||
@pytest.mark.parametrize( | |||
"do_init_args, expected_do_dict, divide_by_zero_warning_expected", | |||
[ | |||
( # instantiate just array attributes | |||
( # Instantiate just array attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's use that convention. For the test cases I don't mind if they are full sentences or not tbh as long as the intent is clear.
# 2. Empty q values, wavelength specified, return empty arrays | ||
# Test conversion of q to tth with valid values | ||
# C1: Allow empty array q to compute tth with or without wavelength | ||
# 1. Wavelength provided, expect empty array of tth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your version looks great here
Very clear
Right, method docstring also doesn't have to start with a complete "noun-verb" sentences anyway.. so i agree. |
No description provided.