Skip to content

Use clear errors for invalid annotation writer inputs #797

Done

Description

@tompollard

write_annotations and Annotation.write pass some validation failures through from the legacy annotation writer as tuple-valued exceptions. The new path-based API should report plain, specific messages.

Examples:

wfdb.Annotation("x", "atr", np.array([1])).write("x.atr")
# Exception: ('At least one annotation label field is required ...', (...))

wfdb.Annotation("x", "atr", [], symbol=[]).write("x.atr")
# TypeError: ('The sample field must be one of the following types:', (...))

The first case should raise ValueError explaining that a non-empty annotation needs a label field. The second should raise TypeError explaining that sample must be a one-dimensional NumPy array. Keep validation and error messages consistent between write_annotations and Annotation.write; add focused tests for both cases.

Follow-up to #796. Empty annotations are valid there; this issue concerns invalid inputs to the new writers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions