Skip to content

Commit cb0aa2f

Browse files
committed
to runtime and int test
1 parent 8e01f63 commit cb0aa2f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

numcodecs/fletcher32.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Fletcher32(Codec):
3434
val = H5_checksum_fletcher32(&b_ptr[0], b.nbytes - 4)
3535
found = b[-4:].view("<u4")[0]
3636
if val != found:
37-
raise ValueError(
37+
raise RuntimeError(
3838
f"The fletcher32 checksum of the data ({val}) did not"
3939
f" match the expected checksum ({found}).\n"
4040
"This could be a sign that the data has been corrupted."

numcodecs/tests/test_fletcher32.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ def test_error():
2121
enc = f.encode(data)
2222
enc2 = bytearray(enc)
2323
enc2[0] += 1
24-
with pytest.raises(ValueError) as e:
24+
with pytest.raises(RuntimeError) as e:
2525
f.decode(enc2)
2626
assert "fletcher32 checksum" in str(e.value)
2727

2828

2929
def test_known():
3030
data = (
31-
b'\xf04\xfe\x1a\x03\xb2\xb1?^\x99j\xf3\xd6f\xef?\xbbm\x04n'
32-
b'\x9a\xdf\xeb?x\x9eIL\xdeW\xc8?A\xef\x88\xa8&\xad\xef?'
33-
b'\xf2\xc6a\x01a\xb8\xe8?#&\x96\xabY\xf2\xe7?\xe2Pw\xba\xd0w\xea?'
34-
b'\x80\xc5\xf8M@0\x9a?\x98H+\xb4\x03\xfa\xc6?\xb9P\x1e1'
35-
)
31+
b'w\x07\x00\x00\x00\x00\x00\x00\x85\xf6\xff\xff\xff\xff\xff\xff'
32+
b'i\x07\x00\x00\x00\x00\x00\x00\x94\xf6\xff\xff\xff\xff\xff\xff'
33+
b'\x88\t\x00\x00\x00\x00\x00\x00i\x03\x00\x00\x00\x00\x00\x00'
34+
b'\x93\xfd\xff\xff\xff\xff\xff\xff\xc3\xfc\xff\xff\xff\xff\xff\xff'
35+
b"'\x02\x00\x00\x00\x00\x00\x00\xba\xf7\xff\xff\xff\xff\xff\xff"
36+
b'\xfd%\x86d')
3637
data3 = Fletcher32().decode(data)
37-
outarr = np.frombuffer(data3, dtype="<f8")
38+
outarr = np.frombuffer(data3, dtype="<i8")
3839
expected = [
39-
0.0691225, 0.98130367, 0.87104532, 0.19018153, 0.9898866,
40-
0.77250719, 0.74833377, 0.8271259, 0.02557469, 0.17950484
40+
1911, -2427, 1897, -2412, 2440, 873, -621, -829, 551, -2118,
4141
]
42-
assert np.allclose(outarr, expected)
42+
assert outarr.tolist() == expected

0 commit comments

Comments
 (0)