From f684ed3a73b80ca94a84b5728a7d036d0f6f0cb7 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Tue, 22 Oct 2024 12:15:08 +0100 Subject: [PATCH 1/2] Avoid silent overflow for numpy compatibility --- harp/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harp/io.py b/harp/io.py index b87c1f7..374018d 100644 --- a/harp/io.py +++ b/harp/io.py @@ -90,7 +90,7 @@ def read( micros = np.ndarray(nrows, dtype=np.uint16, buffer=data, offset=payloadoffset, strides=stride) payloadoffset += 2 time = micros * _SECONDS_PER_TICK + seconds - payloadtype = payloadtype & ~0x10 + payloadtype = payloadtype & ~np.uint8(0x10) if epoch is not None: time = epoch + pd.to_timedelta(time, "s") # type: ignore index = pd.Series(time) From 750bb53d854eb9bcbbb1761b6dcc9d52ca84cac7 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Tue, 29 Oct 2024 10:26:05 +0000 Subject: [PATCH 2/2] Ensure stride uses default int type --- harp/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harp/io.py b/harp/io.py index 374018d..8c4bf96 100644 --- a/harp/io.py +++ b/harp/io.py @@ -80,7 +80,7 @@ def read( raise ValueError(f"expected address {address} but got {data[2]}") index = None - stride = data[1] + 2 + stride = int(data[1] + 2) nrows = len(data) // stride payloadtype = data[4] payloadoffset = 5