Skip to content

RF+BF: Add tolerances and data types for nib-diff, remove hypothesis dependency #678

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

Merged
merged 24 commits into from
Oct 11, 2018

Conversation

yarikoptic
Copy link
Member

As pointed by a few added tests, comparison wasn't doing proper job, especially in the light of comparing NaN values. For the purpose of this function we would like to assume that two NaNs are equal - we are comparing different headers so bringing the difference were both have NaNs is not desired.

Attn @chrispycheng - please review the changes. Since there were no tests pointing specifically what was the intention from the code comparing for NaNs, I had difficult time figuring out what we wanted to say.

yarikoptic and others added 17 commits September 14, 2018 16:38
…differences to tolerate

So now it should be possible to get an idea on how much data in the given files differs:

    $> nib-diff --ma 0.000001 --mr .001 ./tests-run/output/./sub-1_T1w_5mm_noise_corrected.nii.gz /tmp/sub-1_T1w_5mm_noise_corrected.nii.gz
    These files are different.
    Field          1:sub-1_T1w_5mm_noise_corrected.nii.gz                   2:sub-1_T1w_5mm_noise_corrected.nii.gz
    DATA(md5)      65df09c06b236342eaf7e2fe57aabf55                       3c6e9069e6e054e714f2894419848df0
    DATA(diff 1:)  -                                                      abs: 7.6293945e-06, rel: 0.002224694
…hanged value output in data_diff function to allow for validation of data type
Proved to give some troubles along the way and its use
was quite basic and only in one tests module.  So - replaced
with simpler straightforward tests
Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't check for cases that didn't get covered (leaving that to @chrispycheng), but a couple minor style issues. Otherwise, LGTM.

y = data.draw(st.floats(min_value=1e8), label='y')
z = data.draw(st.floats(max_value=-1e8), label='z')
def test_diff_values_int():
long = 10**30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long is a keyword in Python 2. Maybe large?

return True
elif np.any(value0 != value):
return True
elif value0 is np.NaN:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Numpy prefers you to use np.nan. I don't know if this means they plan to remove the synonyms in the future or if it's just a style thing. I'd go with their recommendation, though.

Also appears in the test file.

Recommendataions by @effigies
- long is a keyword
- numpy.nan is recommended over numpy.NaN
@yarikoptic
Copy link
Member Author

Thank you @effigies - pushed 1996ead .

@effigies
Copy link
Member

effigies commented Oct 8, 2018

@chrispycheng Are you happy with this PR?

@coveralls
Copy link

coveralls commented Oct 8, 2018

Coverage Status

Coverage increased (+0.01%) to 91.84% when pulling 3636c4d on yarikoptic:no-hypothesis into 7877add on nipy:master.

@codecov-io
Copy link

codecov-io commented Oct 8, 2018

Codecov Report

Merging #678 into master will decrease coverage by 0.03%.
The diff coverage is 85.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #678      +/-   ##
==========================================
- Coverage   88.86%   88.83%   -0.04%     
==========================================
  Files          93       93              
  Lines       11378    11434      +56     
  Branches     1869     1890      +21     
==========================================
+ Hits        10111    10157      +46     
- Misses        930      935       +5     
- Partials      337      342       +5
Impacted Files Coverage Δ
nibabel/cmdline/diff.py 90.97% <85.54%> (-5.62%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7877add...3636c4d. Read the comment docs.

@yarikoptic
Copy link
Member Author

Finally tests are green!

@yarikoptic
Copy link
Member Author

@chrispycheng please look at https://codecov.io/gh/nipy/nibabel/pull/678/src/cmdline/diff.py and add those missing tests so we get all cases covered (ignore the uncovered reraising the exception case)

@chrispycheng
Copy link
Contributor

@effigies I'm going to sort out the coverage Yarik mentioned and then we should be good to go

@chrispycheng
Copy link
Contributor

@yarikoptic @effigies Changes are fired up and ready to go with Travis passing and increased coverage. AppVeyor is causing trouble again but not due to anything from this commit.

@effigies effigies changed the title RF+BF: prune use of hypothesis, fixed comparison for values being different RF+BF: Add tolerances and data types for nib-diff, remove hypothesis dependency Oct 11, 2018
@effigies
Copy link
Member

@yarikoptic If you're happy with this, want to merge?

@yarikoptic
Copy link
Member Author

Ok, let's do it! thanks @effigies and @chrispycheng

@yarikoptic yarikoptic merged commit def0364 into nipy:master Oct 11, 2018
@nibotmi nibotmi mentioned this pull request Oct 11, 2018
@yarikoptic yarikoptic deleted the no-hypothesis branch October 12, 2018 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants