Repository navigation
Add formats alias to Record - #812
Conversation
tompollard
left a comment
There was a problem hiding this comment.
Thanks. formats shares one list with fmt through copies and pickling, both constructor spellings are rejected together, channel selection keeps the right format, and an edited format reaches the written header. Leaving it off MultiRecord matches samples_per_frame. The offline suite, Ruff and the strict docs build pass locally.
One difference from the other new names: samples_per_frame, n_signals, n_frames, channels and the annotation aliases all validate assignments through the new spelling, but formats stores anything. "16", [16], ["999"], ("16", "16") and ["16", None] are all accepted, and only fail at write time, some with legacy-style messages: a tuple gives TypeError: Field 'fmt' must be a list., and ["16", None] gives TypeError: ('Channel 1 of field 'fmt' must be one of the following types:', ...). All 82 sample headers produce lists of strings, so validating on assignment wouldn't reject anything the readers produce. Could the setter and constructor keyword require None or a list of strings, each a known WFDB format code (including read-only ones such as 310, with writability still checked when saving), leaving fmt unchanged?
|
Thanks, I agree. |
Summary
Add
Record.formatsas a mutable alias for the per-channelfmtlist in #672. The constructor accepts either spelling and rejects both together. Reads, copies, pickling, and writes use the same stored list.MultiRecordkeeps its segment-level format information and has no top-levelformatsfield.The alias describes WFDB file encoding. Assignments through
formatsacceptNoneor a list of known WFDB format codes, including read-only codes such as310and0for null channels. Directfmtassignment keeps its existing behavior. The writer continues to validate whether the selected formats can be written with the record's files and signal values.Verification