Skip to content

Commit

Permalink
feat: add keyword of args
Browse files Browse the repository at this point in the history
  • Loading branch information
wst24365888 committed Dec 24, 2022
1 parent 33346c6 commit 31e2864
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/streamvbyte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PYBIND11_MODULE(libstreamvbyte, m) {

return out;
},
py::arg("in"),
"Encode an array of unsigned integers into a byte array.");

m.def(
Expand All @@ -42,6 +43,7 @@ PYBIND11_MODULE(libstreamvbyte, m) {

return out;
},
py::arg("in"), py::arg("size"),
"Decode a byte array into an array of unsigned integers.");

m.def(
Expand All @@ -59,6 +61,7 @@ PYBIND11_MODULE(libstreamvbyte, m) {

return out;
},
py::arg("in"),
"Encode an array of signed integers into an array of unsigned integers.");

m.def(
Expand All @@ -76,6 +79,7 @@ PYBIND11_MODULE(libstreamvbyte, m) {

return out;
},
py::arg("in"),
"Decode an array of unsigned integers into an array of signed integers.");

m.def(
Expand Down
16 changes: 10 additions & 6 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
def test_streamvbyte():
original_data = np.random.randint(0, 2**32, N, dtype=np.uint32)

compressed_bytes = svb.encode(original_data)
compressed_bytes = svb.encode(in=original_data)
assert type(compressed_bytes) == np.ndarray
assert compressed_bytes.dtype == np.uint8

recovered_data = svb.decode(compressed_bytes, N)
recovered_data = svb.decode(in=compressed_bytes, size=N)
assert type(recovered_data) == np.ndarray
assert recovered_data.dtype == np.uint32

Expand All @@ -22,11 +22,11 @@ def test_streamvbyte():
def test_zigzag():
original_data = np.random.randint(-2**31, 2**31, N, dtype=np.int32)

encoded_unsigend_integers = svb.zigzag_encode(original_data)
encoded_unsigend_integers = svb.zigzag_encode(in=original_data)
assert type(encoded_unsigend_integers) == np.ndarray
assert encoded_unsigend_integers.dtype == np.uint32

recovered_data = svb.zigzag_decode(encoded_unsigend_integers)
recovered_data = svb.zigzag_decode(in=encoded_unsigend_integers)
assert type(recovered_data) == np.ndarray
assert recovered_data.dtype == np.int32

Expand All @@ -37,11 +37,15 @@ def test_zigzag():
def test_integrate():
original_data = np.random.randint(-2**31, 2**31, N, dtype=np.int32)

compressed_bytes = svb.encode(svb.zigzag_encode(original_data))
compressed_bytes = svb.encode(
in=svb.zigzag_encode(in=original_data)
)
assert type(compressed_bytes) == np.ndarray
assert compressed_bytes.dtype == np.uint8

recovered_data = svb.zigzag_decode(svb.decode(compressed_bytes, N))
recovered_data = svb.zigzag_decode(
in=svb.decode(in=compressed_bytes, size=N)
)
assert type(recovered_data) == np.ndarray
assert recovered_data.dtype == np.int32

Expand Down

0 comments on commit 31e2864

Please sign in to comment.