|
| 1 | +From 0e23a49ddb34fadf72fe0457d23eef066e1a3532 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Alex Jadczak < [email protected]> |
| 3 | +Date: Tue, 27 Jun 2023 12:25:13 -0400 |
| 4 | +Subject: [PATCH] bug-fix: Numpy ValueError when cheking empty list equality |
| 5 | + |
| 6 | +FIX: https://github.com/MIT-LCP/wfdb-python/pull/459 |
| 7 | + |
| 8 | +Using the equality operator with an empty list will result in the |
| 9 | +following error. |
| 10 | + |
| 11 | +ValueError: operands could not be broadcast together with shapes (28,) (0,) |
| 12 | + |
| 13 | +Using len() and inverting the logic avoids this issue. |
| 14 | +--- |
| 15 | + wfdb/io/annotation.py | 6 +++--- |
| 16 | + 1 file changed, 3 insertions(+), 3 deletions(-) |
| 17 | + |
| 18 | +diff --git a/wfdb/io/annotation.py b/wfdb/io/annotation.py |
| 19 | +index 655d121..5cde1ed 100644 |
| 20 | +--- a/wfdb/io/annotation.py |
| 21 | ++++ b/wfdb/io/annotation.py |
| 22 | +@@ -940,10 +940,10 @@ def wr_ann_file(self, write_fs, write_dir=""): |
| 23 | + core_bytes = self.calc_core_bytes() |
| 24 | + |
| 25 | + # Mark the end of the special annotation types if needed |
| 26 | +- if fs_bytes == [] and cl_bytes == []: |
| 27 | +- end_special_bytes = [] |
| 28 | +- else: |
| 29 | ++ if len(fs_bytes) or len(cl_bytes): |
| 30 | + end_special_bytes = [0, 236, 255, 255, 255, 255, 1, 0] |
| 31 | ++ else: |
| 32 | ++ end_special_bytes = [] |
| 33 | + |
| 34 | + # Write the file |
| 35 | + with open( |
0 commit comments