MIT-LCP / wfdb-python

Native Python WFDB package
MIT License
747 stars 301 forks source link

wrann ValueError #461

Open toiflm opened 1 year ago

toiflm commented 1 year ago

When saving annotations, I get this error in wrann:

File "C:\Users\######\venv\Lib\site-packages\wfdb\io\annotation.py", line 943, in wr_ann_file
    if fs_bytes == [] and cl_bytes == []:
       ^^^^^^^^^^^^^^
ValueError: operands could not be broadcast together with shapes (28,) (0,)

This error is raised when fs_bytes (or cl_bytes) is a numpy ndarray that is compared to the empty list. A possible solution may be, to cast the arrays to lists and then compare them:

if list(fs_bytes) == [] and list(cl_bytes) == []:

(WFDB Version: 4.1.2, Python 3.11)

toiflm commented 11 months ago

another suggestion: if len(fs_bytes) == 0 and len(cl_bytes) == 0