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

raise error if no valid timebase specified #139

Merged
merged 2 commits into from
Jan 16, 2023

Conversation

callumrollo
Copy link
Collaborator

alternative solution to #137. Forces user to specify a timebase

@codecov
Copy link

codecov bot commented Dec 9, 2022

Codecov Report

Base: 77.49% // Head: 78.31% // Increases project coverage by +0.81% 🎉

Coverage data is based on head (b2e24ea) compared to base (a32a585).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #139      +/-   ##
==========================================
+ Coverage   77.49%   78.31%   +0.81%     
==========================================
  Files           7        7              
  Lines        1271     1282      +11     
==========================================
+ Hits          985     1004      +19     
+ Misses        286      278       -8     
Impacted Files Coverage Δ
pyglider/seaexplorer.py 81.45% <100.00%> (+2.52%) ⬆️
tests/test_seaexplorer.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

indctd = np.where(~np.isnan(sensor.NAV_DEPTH))[0]
# If present, use the timebase specified in ncvar: timebase in the
# deployment yaml.
if 'timebase' not in ncvar:
Copy link
Member

Choose a reason for hiding this comment

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

We can probably make a little test for this behaviour by loading a file, and removing 'timebase' from the parsing of it, and checking for this error. I know that seems a little contrived, but testing behaviour is a way of documenting it so someone doesn't see this, and wonder why we don't have a fallback ;-)

if 'timebase' not in ncvar:
raise ValueError("Must specify timebase:source in netcdf_variables section of deployment yaml")
if ncvar['timebase']['source'] not in sensor.columns:
raise ValueError(f"timebase source: {ncvar['timebase']['source']} not found in pld1 columns")
Copy link
Member

Choose a reason for hiding this comment

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

Same here we could load a parquet file, remove the sensor and trip the error?

@callumrollo
Copy link
Collaborator Author

This commit adds tests for a timebase that doesn't match any of the variables and for if the timebase has been dropped from the yaml. In both cases, we check the error string for the expected error message.

@callumrollo callumrollo requested a review from jklymak December 15, 2022 14:01
@callumrollo
Copy link
Collaborator Author

@jklymak is this ready to merge with the added test?

@jklymak jklymak merged commit f496be6 into c-proof:main Jan 16, 2023
@jklymak
Copy link
Member

jklymak commented Jan 16, 2023

Note I think that we should force timebase for slocums as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants