Issues with user-defined codecs
- Ngôn ngữ chính
- Python
- Star
- 211
- Fork
- 58
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 6
Mô tả
I'm facing issues when creating a simple codec that just makes a copy of the data to get familiar with Blosc's registering machinery. I attach the code:
```python
import blosc2
import numpy as np
# Create an User-defined codec (just a memcpy)
def encoder(input, output, meta, schunk: blosc2.SChunk):
print(f"Encoder output size: {output.size}")
output[:schunk.blocksize] = input[:schunk.blocksize]
return schunk.blocksize
def decoder(input, output, meta, schunk: blosc2.SChunk):
output[:schunk.blocksize] = input[:schunk.blocksize]
return schunk.blocksize
# Register the codec
codec_id = 200
blosc2.register_codec('test1', codec_id, encoder, decoder)
# Compress this array with the new codec
shape = (100, 100)
a = np.ones(shape, dtype=np.int64)
cparams = {
'codec': codec_id,
'nthreads': 1,
'filters': [],
'splitmode': blosc2.SplitMode.NEVER_SPLIT,
}
dparams = {
'nthreads': 1,
}
chunks = shape
blocks = (50, 50)
c_a = blosc2.asarray(a, chunks=chunks, blocks=blocks, cparams=cparams, dparams=dparams)
```
However, when I run the previous code, I get the following:
```
Encoder output size: 20000
Encoder output size: 20000
Encoder output size: 20000
Encoder output size: 19968
ValueError: could not broadcast input array from shape (20000,) into shape (19968,)
```
Looking at this, it appears that the last block of the chunk is smaller than the others. Do you know what is happening? Is there something I'm doing wrong?
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện ví dụ Python được cung cấp và đọc các callback của register_codec cùng với cấu hình block của asarray. So sánh kích thước đầu vào và đầu ra của block cuối cùng, sau đó xác định codec nên xử lý block không đầy đủ đó như thế nào; được coi là hoàn tất khi ví dụ chạy xong mà không có broadcast error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- numpy, python
- Lĩnh vực
- data
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100