-
Notifications
You must be signed in to change notification settings - Fork 76
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
Apply Mask Changes: Multichannel, Allow Depth, Simplify Fill Value #1230
Apply Mask Changes: Multichannel, Allow Depth, Simplify Fill Value #1230
Conversation
… this change into tests
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1230 +/- ##
==========================================
+ Coverage 83.29% 92.97% +9.67%
==========================================
Files 64 3 -61
Lines 5675 185 -5490
==========================================
- Hits 4727 172 -4555
+ Misses 948 13 -935
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
… test that currently needs to be refactored
Original Checklist Remove np.ndarray from allowed type for fill_value
Further Changes
|
echopype/mask/api.py
Outdated
Can be a single input or list that corresponds to a DataArray or a path. | ||
Each entry in the list must have dimensions ``('ping_time', 'range_sample')``. | ||
Multi-channel masks are not currently supported. | ||
Can be a individual input or list that corresponds to a DataArray or a path. |
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.
small fix
Can be a individual input or list that corresponds to a DataArray or a path. | |
Can be a individual input or a list that corresponds to a DataArray or a path. |
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 for the changes @ctuguinay! The core changes for expanding this function to allow data variables with the depth
coordination (in addition to range_sample
) looks good and to simplify fill value specification look good.
I have a more overarching comment about the what we expect in the input arguments. Right now the code is set up to be super flexible and catch as much cases as possible if there are mismatches between source_ds
and mask_list
. I think that we can reduce the code complexity significantly if we impose some expectations on the input arguments to be responsibility of the users. This is also because I think the current code does not actually catch all the things that could go wrong in the mismatches, so it may be better to not try to accommodate some scenarios but not others.
My suggestions are the following:
- If the mask(s) in
mask_list
have thechannel
dimension, we require thatsource_ds
and all elements inmask_list
have the samechannel
coordinates and the shapes are the same (acrosschannel
,ping_time
, andrange_sample
ordepth
). - If the mask(s) in
mask_list
do not have thechannel
dimension, we require thatsource_ds
and all elements inmask_list
have the same shape (acrossping_time
andrange_sample
ordepth
). - The above requires users to slice their masks and/or Sv dataset at the input.
- This will remove the need for the
keep_unmasked_channel
argument. I think allowing this variable would potentially make the data processing pipeline very messy, since the shape of the dataset could change somewhat unpredictably depending on this argumentkeep_unmasked_channel
. If people only want to apply masks to a subset of the channels, they could put 1s for all data in the channels that are not masked.
Let me know what you think.
Thanks for the review @leewujung! Yeah, I agree with you on there being too many cases that this code tries to accommodate. I also agree with you on all suggestions you posed. Just to get the cases in order, once we get to the post-broadcast post-logical-reduce stage (once we get to here https://github.com/ctuguinay/echopype/blob/e52e05f33a82d1700d24f5c58d072fe15d319136/echopype/mask/api.py#L335), I should pass only the following:
|
@leewujung This PR should be ready to review again |
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 changes look good. I suggested some small edits for the docstring and error messages. It is important to be as clear as possible about these things. I think this is ready to be merged -- thanks for the changes!
Co-authored-by: Wu-Jung Lee <[email protected]>
Co-authored-by: Wu-Jung Lee <[email protected]>
…g more precise Co-authored-by: Wu-Jung Lee <[email protected]>
@leewujung I just committed your suggestions, and this should be ready to merge. Thank you for making the docstring more precise! I think I wrote that right after I got tests working so I was at the point of complete familiarity, and I didn't stop to think whether or not someone new could understand it. I will work on that 👍 |
Thanks @ctuguinay , I'll merge this now! 🎉 |
Oops, I just realized that you target |
Looks like there's no compounding changes from other PRs that have been merged to |
This PR is meant to address #1204 and #1224.