Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace bytes of compressed stream with uint8_t #106

Merged
merged 21 commits into from
Oct 1, 2020
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions python/zfpy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cython
from libc.stdlib cimport malloc, free
from cython cimport view
from cpython cimport array
from libc.stdint cimport uint8_t
import array

import itertools
Expand Down Expand Up @@ -245,7 +246,7 @@ cdef _validate_4d_list(in_list, list_name):
)

cpdef np.ndarray _decompress(
bytes compressed_data,
const uint8_t[::1] compressed_data,
zfp_type ztype,
shape,
out=None,
Expand All @@ -260,10 +261,10 @@ cpdef np.ndarray _decompress(
raise ValueError("Cannot decompress in-place")
_validate_4d_list(shape, "shape")

cdef char* comp_data_pointer = compressed_data
cdef const char* comp_data_pointer = <const char*>&compressed_data[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please change this to const void* to avoid any confusion why the pointer is initially cast to a (signed) char*?

cdef zfp_field* field = zfp_field_alloc()
cdef bitstream* bstream = stream_open(
comp_data_pointer,
<void *>comp_data_pointer,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this second cast from const void* to void* necessary, or can comp_data_pointer be declared as void*?

len(compressed_data)
)
cdef zfp_stream* stream = zfp_stream_open(bstream)
Expand Down Expand Up @@ -329,15 +330,15 @@ cpdef np.ndarray _decompress(
return output

cpdef np.ndarray decompress_numpy(
bytes compressed_data,
const uint8_t[::1] compressed_data,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry there may have been an extra space in the suggestion before. Maybe that helps?

Suggested change
const uint8_t[::1] compressed_data,
const uint8_t[::1] compressed_data,

):
if compressed_data is None:
raise TypeError("compressed_data cannot be None")

cdef char* comp_data_pointer = compressed_data
cdef const char* comp_data_pointer = <const char *>&compressed_data[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here; const void* or void*.

cdef zfp_field* field = zfp_field_alloc()
cdef bitstream* bstream = stream_open(
comp_data_pointer,
<void *>comp_data_pointer,
len(compressed_data)
)
cdef zfp_stream* stream = zfp_stream_open(bstream)
Expand Down