Skip to content

Added more informative errors when trying to read netcdf3 - #267

Merged
bnlawrence merged 1 commit into
mainfrom
issue263
Sep 3, 2026
Merged

Added more informative errors when trying to read netcdf3#267
bnlawrence merged 1 commit into
mainfrom
issue263

Conversation

@bnlawrence

@bnlawrencebnlawrence commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Description

The title says it all

Closes#263

Checklist

  • This pull request has a descriptive title and labels
  • This pull request has a minimal description (most was discussed in the issue, but a two-liner description is still desirable)
  • Unit tests have been added (if codecov test fails)
  • Any changed dependencies have been added or removed correctly (if need be)
  • If you are working on the documentation, please ensure the current build passes
  • All tests pass

@bnlawrence
bnlawrence marked this pull request as ready for review September 3, 2026 12:53
@codecov

codecovBot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.59%. Comparing base (8550455) to head (4175eee).

Files with missing linesPatch %Lines
pyfive/high_level.py0.00%4 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #267 +/- ##
==========================================
- Coverage 78.64% 78.59% -0.05% 
==========================================
Files 15 15 Lines 3488 3490 +2 Branches 555 555 ==========================================
Hits 2743 2743 - Misses 602 605 +3 + Partials 143 142 -1 

☔ View full report in Codecov by Harness.
📢 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.

Comment on lines -46 to -47
if contents["format_signature"] != FORMAT_SIGNATURE:
raise InvalidHDF5File("Incorrect file signature")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What happens if someone tries to open some other file (eg txt file)? Will there still be an informative error?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

The superblock is only looked for after the high-level has confirmed it is an HDF5 file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, I got a bit confused here 😬.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

(So, yes)

@davidhasselldavidhassell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All good. Tested on the command line with various files (text, PP, netCDF3, HDF5)

@bnlawrence
bnlawrence merged commit 512ad5a into mainSep 3, 2026
7 of 8 checks passed
@bnlawrence

Copy link
Copy Markdown
CollaboratorAuthor

Argh. The test wasn't uploaded. I blame that ruff check. I'll push that up shortly.

Sign up for freeto 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.

fail gracefully with netcdf3 files

3 participants

@bnlawrence@kmuehlbauer@davidhassell