Skip to content

Commit 88727b5

Browse files
committed
codecov
1 parent 1df045b commit 88727b5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

numcodecs/checksum32.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Checksum32(Codec):
2020
def __init__(self, location: CHECKSUM_LOCATION | None = None):
2121
if location is not None:
2222
self.location = location
23+
if self.location not in ['start', 'end']:
24+
raise ValueError(f"Invalid checksum location: {self.location}")
2325

2426
def encode(self, buf):
2527
arr = ensure_contiguous_ndarray(buf).view('u1')
@@ -28,11 +30,9 @@ def encode(self, buf):
2830
if self.location == 'start':
2931
checksum_view = enc[:4]
3032
payload_view = enc[4:]
31-
elif self.location == 'end':
33+
else:
3234
checksum_view = enc[-4:]
3335
payload_view = enc[:-4]
34-
else:
35-
raise ValueError(f"Invalid checksum location: {self.location}")
3636
checksum_view.view('<u4')[0] = checksum
3737
ndarray_copy(arr, payload_view)
3838
return enc
@@ -47,11 +47,9 @@ def decode(self, buf, out=None):
4747
if self.location == 'start':
4848
checksum_view = arr[:4]
4949
payload_view = arr[4:]
50-
elif self.location == 'end':
50+
else:
5151
checksum_view = arr[-4:]
5252
payload_view = arr[:-4]
53-
else:
54-
raise ValueError(f"Invalid checksum location: {self.location}")
5553
expect = checksum_view.view('<u4')[0]
5654
checksum = self.checksum(payload_view) & 0xFFFFFFFF
5755
if expect != checksum:

0 commit comments

Comments
 (0)