-
Notifications
You must be signed in to change notification settings - Fork 5
ENH: Validate data objects' attributes at instantiation #305
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
a9b3338 to
0e26d53
Compare
|
Notes:
So a refactoring will be required if we go for this. Even if this requires more code than the checks removed in the PRs referenced in issue #302, these are no longer spread across the code base, and we do not run the risk of forgetting checks, or producing e.g. numpy error messages downstream that are harder to debug. |
3c360d6 to
0cd7187
Compare
0cd7187 to
c67bd96
Compare
c67bd96 to
1fc5f1e
Compare
src/nifreeze/data/dmri.py
Outdated
| except (TypeError, ValueError): | ||
| data_vols = None | ||
|
|
||
| if data_vols is not 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.
This is now duplicating par of what _normalize_gradients does: leaving here until PR #327 gets merged.
|
|
||
|
|
||
| @pytest.mark.random_uniform_spatial_data((2, 2, 2, 4), 0.0, 1.0) | ||
| def test_brainmask_volume_mismatch_error(request, setup_random_uniform_spatial_data): |
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.
1fc5f1e to
702e7f2
Compare
src/nifreeze/data/dmri.py
Outdated
| if value is None: | ||
| raise ValueError(GRADIENT_ABSENCE_ERROR_MSG) | ||
| if not isinstance(value, np.ndarray) or value.shape[1] != 4: | ||
| raise ValueError(GRADIENT_SHAPE_ERROR_MSG) |
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 failing for the HDF5 file because it is a 4x102 matrix, and the functions runs before __attrs_post_init__ which would transpose it.
702e7f2 to
fbee186
Compare
22528df to
87893bd
Compare
87893bd to
275fd21
Compare
Validate DWI data objects' attributes at instantiation: ensures that the attributes are present and match the expected dimensionalities.
275fd21 to
3ba23e8
Compare
Validate data objects' attributes at instantiation: ensures that the attributes are present and match the expected dimensionalities.
Fixes #302.