Repository navigation
Add remaining readable Annotation field aliases - #811
Conversation
tompollard
left a comment
There was a problem hiding this comment.
Thanks, this completes the annotation names from #672 using the plural convention, including descriptions. Each pair shares one stored value, both spellings are rejected together in the constructor, sample_indices can replace the positional sample, and failed assignments leave the existing field untouched. I assigned every field of the real annotation files in sample-data (.atr, .qrs, .wabp, .wqrs, read with symbols only and with all label fields) back through the new names, 85 assignments with no failures, so the stricter setters accept what the readers produce. Unmapped symbols from raw codes still write losslessly. The offline suite, Ruff and the strict docs build pass locally.
One change I'd make before merging: n_annotations is a writable alias of ann_len with no validation, and it can go stale. On read_annotations("sample-data/100.atr", stop=2000), trimming sample and the other fields to 3 entries through the existing names leaves n_annotations == 8, and n_annotations = 99 and n_annotations = "5" are both accepted. Unlike a record, an annotation always has its positions, so the count is always len(sample_indices), and the declared-count reasoning from #744 doesn't apply. Could n_annotations be a read-only property returning len(self.sample), leaving ann_len as is?
|
Thanks, I agree. |
Summary
Complete the annotation attribute naming step from #672 after #810 added
channels. Addsample_indices,symbols,subtypes,numbers,notes,label_codes,descriptions, andn_annotationsalongside the existing names. The new per-annotation names also work as constructor keywords, and the constructor rejects values supplied under both spellings. Each value alias refers to one stored value; the existing names remain writable with their current behavior.n_annotationsis read-only and always returns the current length ofsample_indices, even if the legacyann_lenvalue is stale.sample_indicesmakes clear that the array contains positions in a signal, not signal values. The new setters check the existing field rules without changing direct assignments through the legacy names. Unmapped symbols and descriptions from raw label codes can still be assigned through the new names and written losslessly.Verification