Skip to content

Add logical Record metadata snapshot - #767

Merged
tompollard merged 4 commits into
mainfrom
record-metadata-snapshot
Nov 29, 2026
Merged

tompollard merged 4 commits into
mainfrom
record-metadata-snapshot

Conversation

@tompollard

@tompollard tompollard commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Add Record.metadata as an immutable snapshot of the current logical Record view. This is the next small step toward #743 and #371 after the source-header API in #763.

The snapshot reports the record's frame and channel counts, sampling frequency, base date and time, comments, per-channel names, units, and calibration when defined. loaded_forms lists every signal array currently present, including both physical and digital forms after conversion. File names, formats, skew, and other source layout fields stay in the separate source-header model.

Existing mutable Record attributes remain authoritative. Accessing metadata builds a new frozen object each time, so an in-place edit appears in the next snapshot without maintaining a second mutable copy. Counts come from sig_len and n_sig, so callers who manually resize an array must update those attributes too. If channel attribute lists have inconsistent lengths during an edit, signals is None while the other metadata remains available. The property is limited to Record; MultiRecord needs a separate decision about logical channel metadata and segment layout (#746).

This is based on the released 5.7.0 main branch. It does not change the legacy read or write APIs.

Checks

  • Full offline suite: 996 passed, 4 skipped, 21 network tests deselected.
  • Focused metadata tests: 20 passed.
  • Ruff format and lint passed.
  • Sphinx HTML build passed with warnings treated as errors.

@tompollard
tompollard force-pushed the record-metadata-snapshot branch from 93f309a to 5d6a3dc Compare November 29, 2026 10:02
@tompollard
tompollard marked this pull request as ready for review November 29, 2026 10:05
@tompollard

tompollard commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Record.metadata now lists every present array in loaded_forms, so a record with both p_signal and d_signal reports both forms and remains inspectable through hasattr, getattr, and inspect.getmembers. I also changed inconsistent channel lists during an edit to yield signals=None while preserving the rest of the snapshot. The docs now say explicitly that frame and channel counts come from sig_len and n_sig, not array shapes.

I removed samples_per_frame from the channel snapshot: a single number would be ambiguous when uniform and expanded arrays coexist. I kept the logical snapshot and source header classes separate because their similarly named fields describe different things; sharing a base now would couple those meanings. The updated tests cover the conversion paths and mixed layouts. The offline suite passes (993 passed, 4 skipped; 21 network tests deselected), as do Ruff and the strict docs build.

@tompollard

Copy link
Copy Markdown
Member Author

I also addressed the three nonblocking cases from the re-review in 5531bb8. Invalid n_sig now leaves the channel count unknown, a scalar channel field yields signals=None, and a single string comment remains one comment. The 20 metadata tests, full offline suite (996 passed, 4 skipped), Ruff, and strict docs build pass locally. This does not change the behavior of valid records.

@tompollard
tompollard merged commit aef3246 into main Nov 29, 2026
19 checks passed
@tompollard
tompollard deleted the record-metadata-snapshot branch November 29, 2026 10:32
tompollard added a commit that referenced this pull request Nov 29, 2026
## Summary

Prepare WFDB-Python 5.8.0 after the merged, additive metadata work in
#767 and #770. This bumps the version to 5.8.0 and collects the two
changelog fragments. #769 also clarified the existing multi-segment read
contract. The legacy `rdrecord`, `rdheader`, and writer behavior remains
unchanged.

- `Record.metadata` provides an immutable snapshot of the current
logical view and reports every loaded signal form.
- `read_multi_segment_headers` reads the main multi-segment header plus
the layout header (or first non-gap data segment header for fixed
layout), without loading samples or all segment headers.

## Checks

- `uv build` produced the 5.8.0 source distribution and wheel.
- Sphinx HTML build passed with warnings treated as errors.
- `git diff --check` passed.
- The feature PRs passed CI before merging; this release PR will run CI
again.
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.

1 participant