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

Add warnings and raised errors for add_location #1296

Merged

Conversation

ctuguinay
Copy link
Collaborator

Add warnings for add_location for NaN/0 lat/lon and duplicated timestamps to address the following issues:
Strange GPS coordinates appearing with add_location() method #1286
add_location fails with duplicated timestamps in GPS data #1294

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ctuguinay ctuguinay marked this pull request as ready for review April 4, 2024 23:25
@ctuguinay ctuguinay requested a review from leewujung April 4, 2024 23:30
@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.66%. Comparing base (9f56124) to head (c8e5ef5).
Report is 41 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1296      +/-   ##
==========================================
+ Coverage   83.52%   91.66%   +8.14%     
==========================================
  Files          64        3      -61     
  Lines        5686      168    -5518     
==========================================
- Hits         4749      154    -4595     
+ Misses        937       14     -923     
Flag Coverage Δ
unittests 91.66% <100.00%> (+8.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ctuguinay
Copy link
Collaborator Author

Oh wait, I'll add some tests to cover these scenarios.

@ctuguinay ctuguinay marked this pull request as draft April 4, 2024 23:39
@ctuguinay ctuguinay marked this pull request as ready for review April 5, 2024 04:27
@ctuguinay
Copy link
Collaborator Author

@leewujung This PR should be ready for review now

@ctuguinay ctuguinay self-assigned this Apr 5, 2024
@ctuguinay ctuguinay added bug Something isn't working enhancement This makes echopype better labels Apr 5, 2024
Comment on lines 213 to 222

# Check if there are duplicates in time_dim_name
if len(np.unique(echodata["Platform"][time_dim_name].data)) != len(
echodata["Platform"][time_dim_name].data
):
logger.warning(
f'The echodata["Platform"]["{time_dim_name}"] array contains duplicate values. '
"Interpolation expects unique time values."
)

Copy link
Member

Choose a reason for hiding this comment

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

I think this should raise an error instead of a warning? Because the underlying code would actually raise a warning. This is as opposed to the GPS NaN/0 cases that the underlying code would run through without erroring out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I see. I think I misinterpreted your original statement here: #1294 (comment). I assumed that meant letting Pandas call the error and we provide a warning message prior to showing the user where the error occurred

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see, no problem!

@ctuguinay ctuguinay changed the title Add warnings for add_location Add warnings and raised errors for add_location Apr 8, 2024
@ctuguinay
Copy link
Collaborator Author

@leewujung Made the switch from warning to raised value error. This should be ready for a quick review again.

@@ -204,7 +204,7 @@ def sel_interp(var, time_dim_name):
).any()
interp_msg = (
"Interpolation may be negatively impacted, "
"consider handling these values before calling add_location."
"consider handling these values before calling ``add_location``."
Copy link
Member

@leewujung leewujung Apr 15, 2024

Choose a reason for hiding this comment

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

Do you know if the error/earning messages would be formatted if one uses backticks ? I know it would be rendered in docstrings, but not sure about the printout messages. I guess this is useful regardless because users would know the thing in the quote is a variable?

Copy link
Member

@leewujung leewujung left a comment

Choose a reason for hiding this comment

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

Looks good! Feel free to merge this.

@leewujung leewujung merged commit cd942eb into OSOceanAcoustics:main Apr 15, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement This makes echopype better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants