Skip to content
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

PyTables Error-handling #1307

Merged
merged 6 commits into from Jul 30, 2017
Merged

PyTables Error-handling #1307

merged 6 commits into from Jul 30, 2017

Conversation

skoudoro
Copy link
Member

The goal of this PR is to resolve #1306.

@arokem @aarya22, can you have a look ?

Thanks !

@aarya22
Copy link
Contributor

aarya22 commented Jul 24, 2017

Nice job on fixing the NameError.

Copy link
Contributor

@arokem arokem left a comment

Choose a reason for hiding this comment

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

LGTM overall. A couple of small questions regarding the error that gets raised.

odf = None
affine = pam.affine if hasattr(pam, 'affine') else affine
shm_coeff = pam.shm_coeff if hasattr(pam, 'shm_coeff') else None
odf = pam.odf if hasattr(pam, 'odf') else None
Copy link
Contributor

Choose a reason for hiding this comment

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

Elegant

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks ;-)

pam.odf = np.zeros((10, 10, 10, sphere.vertices.shape[0]))

if not have_tables:
npt.assert_raises(TripWireError, save_peaks, fname, pam)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this might raise an ImportError?

Copy link
Member Author

Choose a reason for hiding this comment

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

save_peaks raise TripWireError , however _safe_save raise ImportError, so it is ok here. To be more consistent, I generate a TripWireError via a fake call in _safe_save now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the error handling in _safe_save tested elsewhere? Would you mind writing a test, if it isn't?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 test added

dipy/io/peaks.py Outdated
else:
func_create_carray = f.create_carray
if not have_tables:
raise ImportError('PyTables is not installed')
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some way to get the TripWireError here (instead of an ImportError?)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 85.425% when pulling d3d017b on skoudoro:issue_1306_pytables into 08d8d90 on nipy:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 85.425% when pulling d3d017b on skoudoro:issue_1306_pytables into 08d8d90 on nipy:master.

@codecov-io
Copy link

codecov-io commented Jul 24, 2017

Codecov Report

Merging #1307 into master will decrease coverage by 0.03%.
The diff coverage is 75.51%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1307      +/-   ##
=========================================
- Coverage   87.13%   87.1%   -0.04%     
=========================================
  Files         228     228              
  Lines       28800   28816      +16     
  Branches     3093    3092       -1     
=========================================
+ Hits        25094   25099       +5     
- Misses       3003    3014      +11     
  Partials      703     703
Impacted Files Coverage Δ
dipy/io/dpy.py 94.02% <100%> (+1.38%) ⬆️
dipy/io/tests/test_io_peaks.py 89.81% <73.68%> (-7.66%) ⬇️
dipy/io/peaks.py 89.79% <80%> (-2.66%) ⬇️

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 08d8d90...2b0af87. Read the comment docs.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 85.425% when pulling d3d017b on skoudoro:issue_1306_pytables into 08d8d90 on nipy:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 85.425% when pulling d3d017b on skoudoro:issue_1306_pytables into 08d8d90 on nipy:master.

Copy link
Contributor

@arokem arokem left a comment

Choose a reason for hiding this comment

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

This is converging. Just one more question about the test.

func_create_carray = f.create_carray
if not have_tables:
# We generate a TripWireError via this call
_ = tables.any_attributes
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

This seems fine to me.

pam.odf = np.zeros((10, 10, 10, sphere.vertices.shape[0]))

if not have_tables:
npt.assert_raises(TripWireError, save_peaks, fname, pam)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the error handling in _safe_save tested elsewhere? Would you mind writing a test, if it isn't?

@coveralls
Copy link

coveralls commented Jul 25, 2017

Coverage Status

Coverage decreased (-0.03%) to 85.405% when pulling 2b0af87 on skoudoro:issue_1306_pytables into 08d8d90 on nipy:master.

@arokem
Copy link
Contributor

arokem commented Jul 25, 2017

+1 for the merge from me. Anyone else want to take a look?

If not, I will merge in a couple of days.

@arokem arokem merged commit 0c10a43 into dipy:master Jul 30, 2017
@skoudoro skoudoro deleted the issue_1306_pytables branch July 31, 2017 13:35
ShreyasFadnavis pushed a commit to ShreyasFadnavis/dipy that referenced this pull request Sep 20, 2018
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.

Error-handling when pytables not installed
5 participants