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
PyTables Error-handling #1307
Conversation
Nice job on fixing the NameError. |
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.
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 |
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.
Elegant
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.
Thanks ;-)
pam.odf = np.zeros((10, 10, 10, sphere.vertices.shape[0])) | ||
|
||
if not have_tables: | ||
npt.assert_raises(TripWireError, save_peaks, fname, pam) |
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.
Looks like this might raise an ImportError
?
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.
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.
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.
Is the error handling in _safe_save
tested elsewhere? Would you mind writing a test, if it isn't?
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.
👍 test added
dipy/io/peaks.py
Outdated
else: | ||
func_create_carray = f.create_carray | ||
if not have_tables: | ||
raise ImportError('PyTables is not installed') |
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.
Is there some way to get the TripWireError here (instead of an ImportError?)
1 similar comment
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
1 similar comment
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.
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 |
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.
👍
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) |
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.
Is the error handling in _safe_save
tested elsewhere? Would you mind writing a test, if it isn't?
+1 for the merge from me. Anyone else want to take a look? If not, I will merge in a couple of days. |
PyTables Error-handling
The goal of this PR is to resolve #1306.
@arokem @aarya22, can you have a look ?
Thanks !