Skip to content

Fix DataFolder.read_dataset for raw 2D datasets without axes - #241

Merged
heevasti merged 1 commit into
mainfrom
claude/issue-240-20261028-0721
Oct 28, 2026
Merged

heevasti merged 1 commit into
mainfrom
claude/issue-240-20261028-0721

Conversation

@claude

@claude claude Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

DataFolder.write_dataset() stores a raw DataSet (data without axes, e.g. plain 2D data) at the root of the HDF5 file, marking it via the QMI_Dataset_name (and related) file attributes. DataFolder.read_dataset() only looked for a child group named after the dataset, so for raw datasets it raised FileNotFoundError even though the file it had just written does contain the data.

This fixes the regression by making read_dataset() fall back to reading the file root when no child group with the given name exists but the root attributes identify it as that raw dataset — for both the h5py and h5netcdf backends.

  • qmi/data/datastore.py: DataFolder.read_dataset() now checks f.attrs[QMI_Dataset_name] as a fallback before raising FileNotFoundError.
  • tests/data/test_datastore.py: added test_29_read_raw_2d_dataset_without_axes_in_hdf5 and test_29b_read_raw_2d_dataset_without_axes_in_hdf5_h5netcdf_backend, covering the write/read round trip for a 2D raw DataSet with both backends.
  • CHANGELOG.md: documented the fix under "Fixed" in the Unreleased section.

Fixes #240

Test plan

  • uv run coverage run --branch -m unittest discover --start-directory="tests" --pattern="test_*.py" — all 3185 tests pass (including the 2 new tests)
  • uv run ruff check --fix --output-format pylint — clean
  • uv run mypy qmi examples --namespace-package --explicit-package-bases — clean (pre-existing unrelated errors in examples/ only)
  • Verified the issue's reproduction script now returns the correct data instead of raising FileNotFoundError, for both backends

🤖 Generated with Claude Code

write_dataset() stores a raw DataSet (no axis set) at the HDF5 file
root instead of in a group named after the dataset. read_dataset()
only looked for a child group with that name, so it raised
FileNotFoundError for a file it had just written. It now falls back
to the file root when the root attributes identify it as the
requested raw dataset, for both the h5py and h5netcdf backends.

Fixes #240

Co-authored-by: heevasti <87366176+heevasti@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@claude
claude Bot requested a review from heevasti October 28, 2026 07:28
@claude claude Bot mentioned this pull request Oct 28, 2026

@heevasti heevasti 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.

Looks good.

@heevasti
heevasti merged commit 3f8db56 into main Oct 28, 2026
11 of 12 checks passed
@heevasti
heevasti deleted the claude/issue-240-20261028-0721 branch October 28, 2026 08:02
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.

QMI dataset reading bug

1 participant