Skip to content

Commit

Permalink
Fix Fletcher32 out and test
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti committed Jul 18, 2023
1 parent 4f194b6 commit cd03a2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numcodecs/fletcher32.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Fletcher32(Codec):
f" match the expected checksum ({found}).\n"
"This could be a sign that the data has been corrupted."
)
if out:
if out is not None:
out.view("uint8")[:] = b[:-4]
return out
return memoryview(b[:-4])
7 changes: 7 additions & 0 deletions numcodecs/tests/test_fletcher32.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ def test_known():
1911, -2427, 1897, -2412, 2440, 873, -621, -829, 551, -2118,
]
assert outarr.tolist() == expected


def test_out():
data = np.frombuffer(bytearray(b"Hello World"), dtype="uint8")
f = Fletcher32()
result = f.encode(data)
f.decode(result, out=data)

0 comments on commit cd03a2a

Please sign in to comment.