Skip to content

Map Units waveform metadata to waveforms#2183

Draft
ehennestad wants to merge 1 commit intodevfrom
fix-units-waveforms-sampling_rate
Draft

Map Units waveform metadata to waveforms#2183
ehennestad wants to merge 1 commit intodevfrom
fix-units-waveforms-sampling_rate

Conversation

@ehennestad
Copy link
Copy Markdown

Motivation

This change fixes a mismatch between the NWB schema and the PyNWB Units mapper for waveform metadata.

The schema defines sampling_rate and unit attributes on waveform_mean, waveform_sd, and waveforms, but PyNWB only propagated Units.waveform_rate and Units.waveform_unit to waveform_mean and waveform_sd. As a result, a Units table containing only waveforms would lose waveform sampling metadata on write, and waveform_rate would not round-trip on read.

Fix #2182.

What changed

  • Extend the write-side VectorData mapper so Units.waveform_rate and Units.waveform_unit are also written to the waveforms column attributes.
  • Extend the read-side UnitsMap logic so it also considers waveforms when reconstructing waveform metadata.
  • Add an integration test that round-trips a Units table with only waveforms and verifies both the in-memory metadata and the on-disk attributes.

How to test the behavior?

PYTHONPATH=src python -m unittest tests.integration.hdf5.test_misc.TestUnitsWaveformsOnlyIO tests.integration.hdf5.test_misc.TestUnitsIO

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running ruff check . && codespell from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

Prepared with Codex.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.13%. Comparing base (a2d1efa) to head (9af2788).

Files with missing lines Patch % Lines
src/pynwb/io/misc.py 55.55% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2183      +/-   ##
==========================================
+ Coverage   95.10%   95.13%   +0.03%     
==========================================
  Files          29       29              
  Lines        2943     2941       -2     
  Branches      443      441       -2     
==========================================
- Hits         2799     2798       -1     
- Misses         86       87       +1     
+ Partials       58       56       -2     
Flag Coverage Δ
integration 72.86% <60.00%> (+0.01%) ⬆️
unit 85.41% <0.00%> (+0.05%) ⬆️

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.

[Bug]: Units.waveform_rate is not written to /units/waveforms sampling_rate

1 participant