@@ -1566,44 +1566,43 @@ cdef int general_filler(blosc2_prefilter_params *params):
1566
1566
1567
1567
cdef int general_numba(blosc2_prefilter_params * params):
1568
1568
cdef numba_udata * udata = < numba_udata * > params.user_data
1569
- cdef uint8_t nd = udata.ndim
1569
+ cdef uint8_t nd = udata.array. ndim
1570
1570
# off caldrà sumar-li blockshape també
1571
- cdef int64_t offset = params.nchunk * udata.chunkshape + params.output_offset // params.output_typesize
1572
- # shape normal, no extshape, revisar-ho quan hi haja padding
1571
+ cdef int64_t offset = params.nchunk * udata.array.sc.chunksize + params.output_offset // params.output_typesize
1573
1572
cdef int64_t chunk_ndim[B2ND_MAX_DIM]
1574
1573
cdef int64_t chunks_in_array[B2ND_MAX_DIM]
1575
1574
for i in range (nd):
1576
- # Canviar-ho a extshape i chunkshape normal
1577
- chunks_in_array[i] = udata.ext_shape[i] // udata.chunkshape_ndim[i]
1575
+ chunks_in_array[i] = udata.array.extshape[i] // udata.array.chunkshape[i]
1578
1576
blosc2_unidim_to_multidim(nd, chunks_in_array, params.nchunk, chunk_ndim)
1579
- # print("nchunk ", params.nchunk)
1580
1577
1581
1578
cdef int64_t block_ndim[B2ND_MAX_DIM]
1582
1579
cdef int64_t blocks_in_chunk[B2ND_MAX_DIM]
1583
1580
for i in range (nd):
1584
- blocks_in_chunk[i] = udata.chunkshape_ndim [i] // udata.blockshape[i]
1585
- blosc2_unidim_to_multidim(nd, chunks_in_array , params.nblock, block_ndim)
1581
+ blocks_in_chunk[i] = udata.array.extchunkshape [i] // udata.array .blockshape[i]
1582
+ blosc2_unidim_to_multidim(nd, blocks_in_chunk , params.nblock, block_ndim)
1586
1583
1587
1584
cdef int64_t start_ndim[B2ND_MAX_DIM]
1588
1585
for i in range (nd):
1589
- start_ndim[i] = chunk_ndim[i] * udata.chunkshape_ndim [i] + block_ndim[i] * udata.blockshape[i]
1586
+ start_ndim[i] = chunk_ndim[i] * udata.array.chunkshape [i] + block_ndim[i] * udata.array .blockshape[i]
1590
1587
# print("start_ndim[", i, "] = ", start_ndim[i])
1591
1588
1592
1589
padding = False
1593
1590
blockshape = []
1594
1591
for i in range (nd):
1595
1592
if start_ndim[i] + udata.blockshape[i] > udata.shape[i]:
1596
1593
padding = True
1597
- blockshape.append(udata.shape[i] - start_ndim[i])
1594
+ blockshape.append(udata.array.shape[i] - start_ndim[i])
1595
+ if blockshape[i] <= 0 :
1596
+ # This block contains only padding, skip it
1597
+ return 0
1598
1598
else :
1599
- blockshape.append(udata.blockshape[i])
1599
+ blockshape.append(udata.array. blockshape[i])
1600
1600
cdef np.npy_intp dims[B2ND_MAX_DIM]
1601
1601
for i in range (nd):
1602
1602
dims[i] = blockshape[i]
1603
1603
1604
1604
if padding:
1605
- output = np.empty(blockshape, udata.array.dtype) # igual toca crear un py dtype
1606
- print (output.dtype)
1605
+ output = np.empty(blockshape, udata.array.dtype)
1607
1606
else :
1608
1607
output = np.PyArray_SimpleNewFromData(nd, dims, udata.output_cdtype, < void * > params.output)
1609
1608
inputs_tuple = _ctypes.PyObj_FromPtr(udata.inputs_id)
@@ -1612,13 +1611,13 @@ cdef int general_numba(blosc2_prefilter_params *params):
1612
1611
# Enviar-ho a fer la mà quan nd = 1 ? o ho puc suportar sense problemes??
1613
1612
for obj, dtype in inputs_tuple:
1614
1613
if isinstance (obj, blosc2.SChunk):
1615
- out = np.empty(udata.blockshape[0 ], dtype = dtype)
1614
+ out = np.empty(udata.array. blockshape[0 ], dtype = dtype)
1616
1615
obj.get_slice(start = offset, stop = offset + dims[0 ], out = out)
1617
1616
inputs.append(out)
1618
1617
elif isinstance (obj, np.ndarray):
1619
1618
inputs.append(obj[offset : offset + dims[0 ]])
1620
1619
elif isinstance (obj, (int , float , bool , complex )):
1621
- inputs.append(np.full(udata.blockshape[0 ], obj, dtype = dtype))
1620
+ inputs.append(np.full(udata.array. blockshape[0 ], obj, dtype = dtype))
1622
1621
else :
1623
1622
raise ValueError (" Unsupported operand" )
1624
1623
else :
@@ -1652,10 +1651,10 @@ cdef int general_numba(blosc2_prefilter_params *params):
1652
1651
for i in range (nd):
1653
1652
start[i] = 0
1654
1653
slice_shape[i] = blockshape[i]
1655
- blockshape_int64[i] = udata.blockshape[i]
1654
+ blockshape_int64[i] = udata.array. blockshape[i]
1656
1655
buf = < Py_buffer * > malloc(sizeof(Py_buffer))
1657
1656
PyObject_GetBuffer(output, buf, PyBUF_SIMPLE)
1658
- b2nd_copy_buffer(udata.ndim, params.output_typesize,
1657
+ b2nd_copy_buffer(udata.array. ndim, params.output_typesize,
1659
1658
buf.buf, slice_shape, start, slice_shape,
1660
1659
params.output, blockshape_int64, start)
1661
1660
PyBuffer_Release(buf)
0 commit comments