Skip to content

Calculate channel defaults from one snapshot - #847

Merged
tompollard merged 1 commit into
mainfrom
refactor/channel-defaults
Dec 2, 2026
Merged

tompollard merged 1 commit into
mainfrom
refactor/channel-defaults

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

  • Capture the per-channel fields once before calculating header defaults, so defaults and the subsequent write use the same current channel values.
  • Validate channel list types and lengths before applying defaults. Invalid lists now fail without leaving a partially defaulted record.
  • Keep the existing mutable Record lists as the source of truth; supplied lists retain their identity and partial lists are not filled in.

This is a small step toward #749 and #744. It does not change the public record model.

Verification

  • Offline suite: 1,650 passed, 4 skipped, 23 deselected.
  • Ruff format and lint checks passed.
  • Strict Sphinx docs build passed.
  • Compared six representative generated headers against main; all were byte-identical.

This PR is independent of #846.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks. Output is unchanged: wrsamp writes byte-identical files for every record in sample-data, and the writes that fail on the merge base fail the same way here; module-level wfdb.wrsamp output also matches. Calling set_defaults directly now gives the must be a list TypeError for a NumPy fmt (previously "truth value of an array … is ambiguous") and for a tuple fmt (previously accepted, leaving adc_res unset until the write failed). Since every writer already required lists, no write that succeeds today is affected, and write_record still accepts NumPy fields through its list projection. A wrong-length samps_per_frame is still ignored by wrheader(expanded=False) and still gets the same channel-count error from wrsamp. The offline suite, Ruff and the strict docs build pass locally.

Ready to merge.

@tompollard
tompollard merged commit bade99a into main Dec 2, 2026
19 checks passed
@tompollard
tompollard deleted the refactor/channel-defaults branch December 2, 2026 05:15
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