Skip to content

Commit a3600e4

Browse files
committed
cast type to unsigned int
Addresses warning when NPY_PROMOTION_STATE=weak_and_warn that result dtype changed due to the removal of value-based promotion from NumPy. Changed from int32 to int16.
1 parent 56b7d5c commit a3600e4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

wfdb/io/_signal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,8 @@ def wr_dat_file(
23712371

23722372
elif fmt == "16":
23732373
# convert to 16 bit two's complement
2374-
d_signal[d_signal < 0] = d_signal[d_signal < 0] + 65536
2374+
d_signal = d_signal.astype(np.uint16)
2375+
23752376
# Split samples into separate bytes using binary masks
23762377
b1 = d_signal & [255] * tsamps_per_frame
23772378
b2 = (d_signal & [65280] * tsamps_per_frame) >> 8
@@ -2400,7 +2401,8 @@ def wr_dat_file(
24002401

24012402
elif fmt == "32":
24022403
# convert to 32 bit two's complement
2403-
d_signal[d_signal < 0] = d_signal[d_signal < 0] + 4294967296
2404+
d_signal = d_signal.astype(np.uint32)
2405+
24042406
# Split samples into separate bytes using binary masks
24052407
b1 = d_signal & [255] * tsamps_per_frame
24062408
b2 = (d_signal & [65280] * tsamps_per_frame) >> 8

0 commit comments

Comments
 (0)