Skip to content

fix: prevent crashes on zero-length dimensions in echodata conversion#1624

Open
beatfactor wants to merge 1 commit intoOSOceanAcoustics:mainfrom
OceanStreamIO:oceanstream/fix-zero-length-dims
Open

fix: prevent crashes on zero-length dimensions in echodata conversion#1624
beatfactor wants to merge 1 commit intoOSOceanAcoustics:mainfrom
OceanStreamIO:oceanstream/fix-zero-length-dims

Conversation

@beatfactor
Copy link
Copy Markdown
Contributor

Partial/truncated raw files can produce channels with zero pings, causing:

  • Division by zero in set_zarr_encodings() chunk calculation
  • ValueError in _nan_timestamp_handler() on empty ping_time arrays
  • Encoding failure on all-NaN time variables

Changes:

  • utils/coding.py: Skip all-NaN time vars in set_time_encodings(); handle zero-length and scalar dims in set_zarr_encodings()
  • convert/set_groups_base.py: Return [np.nan] cleanly when ping_time arrays are empty in _nan_timestamp_handler()

Partial/truncated raw files (e.g. from autonomous vehicle deployments)
can produce channels with zero pings, causing:
- Division by zero in set_zarr_encodings() chunk calculation
- ValueError in _nan_timestamp_handler() on empty ping_time arrays
- Encoding failure on all-NaN time variables

Changes:
- utils/coding.py: Skip all-NaN time vars in set_time_encodings();
  handle zero-length and scalar dims in set_zarr_encodings()
- convert/set_groups_base.py: Return [np.nan] cleanly when ping_time
  arrays are empty in _nan_timestamp_handler()
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 64.28571% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.53%. Comparing base (a7c2a62) to head (b0fd72c).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
echopype/utils/coding.py 60.00% 8 Missing ⚠️
echopype/convert/set_groups_base.py 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1624      +/-   ##
==========================================
+ Coverage   84.90%   85.53%   +0.62%     
==========================================
  Files          79       79              
  Lines        6998     7010      +12     
==========================================
+ Hits         5942     5996      +54     
+ Misses       1056     1014      -42     
Flag Coverage Δ
unittests 85.53% <64.28%> (+0.62%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants