Skip to content

Commit 16ee14f

Browse files
committed
[FIX] Forgot to massage kwargs for concatenate
1 parent b4deb3a commit 16ee14f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

bench/ndarray/concatenate.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_benchmark(num_arrays=10, size=500, aligned_chunks=False, axis=0):
5050
arrays = []
5151
for i, (shape, chunk_shape) in enumerate(zip(shapes, chunk_shapes)):
5252
arr = blosc2.arange(
53-
i * np.prod(shape), (i + 1) * np.prod(shape), 1, dtype="i4", shape=shape, chunks=chunk_shape
53+
i * np.prod(shape), (i + 1) * np.prod(shape), 1, dtype="i4", shape=shape, chunks=chunk_shape,
5454
)
5555
arrays.append(arr)
5656

@@ -60,7 +60,7 @@ def run_benchmark(num_arrays=10, size=500, aligned_chunks=False, axis=0):
6060

6161
# Time the concatenation
6262
start_time = time.time()
63-
result = blosc2.concatenate(arrays, axis=axis)
63+
result = blosc2.concatenate(arrays, axis=axis, cparams=blosc2.CParams(codec=blosc2.Codec.BLOSCLZ))
6464
duration = time.time() - start_time
6565

6666
return duration, result.shape, data_size_gb
@@ -198,7 +198,7 @@ def main():
198198
print(f"{'=' * 60}")
199199

200200
# Parameters
201-
sizes = [500, 1000, 2000, 4000] #, 10000] # must be divisible by 4 for aligned chunks
201+
sizes = [500, 1000] #, 2000, 4000] #, 10000] # must be divisible by 4 for aligned chunks
202202
num_arrays = 10
203203

204204
# Lists to store results for both axes
@@ -211,7 +211,8 @@ def main():
211211

212212
for axis in [0, 1]:
213213
print(f"\nConcatenating {num_arrays} arrays along axis {axis}")
214-
print(f"{'Size':<10} {'NumPy (GB/s)':<14} {'Unaligned (GB/s)':<18} {'Aligned (GB/s)':<16} {'Alig vs Unalig':<16} {'Alig vs NumPy':<16}")
214+
print(f"{'Size':<10} {'NumPy (GB/s)':<14} {'Unaligned (GB/s)':<18} "
215+
f"{'Aligned (GB/s)':<16} {'Alig vs Unalig':<16} {'Alig vs NumPy':<16}")
215216
print(f"{'-' * 90}")
216217

217218
for size in sizes:

src/blosc2/ndarray.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,6 +3577,7 @@ def concatenate(arrays: list[NDArray], /, axis=0, **kwargs: Any) -> NDArray: #
35773577
f"{arr1.shape} vs {arr2.shape}"
35783578
)
35793579

3580+
kwargs = _check_ndarray_kwargs(**kwargs)
35803581
# Proceed with the actual concatenation
35813582
copy = True
35823583
for arr2 in arrays[1:]:

tests/ndarray/test_concatenate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
def test_concat2(shape1, shape2, dtype, axis):
3333
ndarr1 = blosc2.arange(0, int(np.prod(shape1)), 1, dtype=dtype, shape=shape1)
3434
ndarr2 = blosc2.arange(0, int(np.prod(shape2)), 1, dtype=dtype, shape=shape2)
35-
result = blosc2.concatenate([ndarr1, ndarr2], axis=axis)
35+
cparams = blosc2.CParams(clevel=1)
36+
result = blosc2.concatenate([ndarr1, ndarr2], axis=axis, cparams=cparams)
3637
nparray = np.concatenate([ndarr1[:], ndarr2[:]], axis=axis)
3738
np.testing.assert_almost_equal(result[:], nparray)
3839

@@ -57,6 +58,7 @@ def test_concat3(shape1, shape2, shape3, dtype, axis):
5758
ndarr1 = blosc2.arange(0, int(np.prod(shape1)), 1, dtype=dtype, shape=shape1)
5859
ndarr2 = blosc2.arange(0, int(np.prod(shape2)), 1, dtype=dtype, shape=shape2)
5960
ndarr3 = blosc2.arange(0, int(np.prod(shape3)), 1, dtype=dtype, shape=shape3)
60-
result = blosc2.concatenate([ndarr1, ndarr2, ndarr3], axis=axis)
61+
cparams = blosc2.CParams(codec=blosc2.Codec.BLOSCLZ)
62+
result = blosc2.concatenate([ndarr1, ndarr2, ndarr3], axis=axis, cparams=cparams)
6163
nparray = np.concatenate([ndarr1[:], ndarr2[:], ndarr3[:]], axis=axis)
6264
np.testing.assert_almost_equal(result[:], nparray)

0 commit comments

Comments
 (0)