Skip to content

Commit 4899eae

Browse files
committed
Allow resize of shape 0 arrays
1 parent b116343 commit 4899eae

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

README.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@ Or, you may want to use a codec in an external library already in the system:
142142
143143
cmake -DPREFER_EXTERNAL_LZ4=ON ..
144144
145-
For OpenZL, there are problems with the build seemingly, so, after building and installing into ``build-cmake`` in the ``openzl`` directory, one has to run:
146-
147-
.. code-block:: console
148-
149-
cmake -DPREFER_EXTERNAL_OPENZL=ON -DOPENZL_LIBRARY=$HOME/openzl/build-cmake/install/lib/libopenzl.a -DOPENZL_INCLUDE_DIR=$HOME/openzl/build-cmake/install/include ..
150-
151145
Supported platforms
152146
~~~~~~~~~~~~~~~~~~~
153147

blosc/b2nd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int update_shape(b2nd_array_t *array, int8_t ndim, const int64_t *shape,
184184
array->shape[i] = shape[i];
185185
array->chunkshape[i] = chunkshape[i];
186186
array->blockshape[i] = blockshape[i];
187-
if (shape[i] != 0) {
187+
if (array->chunkshape[i] != 0) {
188188
if (shape[i] % array->chunkshape[i] == 0) {
189189
array->extshape[i] = shape[i];
190190
} else {

tests/b2nd/test_b2nd_full.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ CUTEST_TEST_SETUP(full) {
2525
CUTEST_PARAMETRIZE(shapes, _test_shapes, CUTEST_DATA(
2626
{0, {0}, {0}, {0}}, // 0-dim
2727
{1, {5}, {3}, {2}}, // 1-idim
28+
{1, {1}, {3}, {2}}, // chunks larger than shape
29+
{2, {1, 2}, {3, 3}, {2, 3}}, // chunks larger than shape
2830
{2, {20, 0}, {7, 0}, {3, 0}}, // 0-shape
2931
{2, {20, 10}, {20, 10}, {10, 10}}, // simple 2-dim
3032
{2, {20, 10}, {10, 5}, {10, 5}}, // non-contiguous

tests/b2nd/test_b2nd_resize.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ CUTEST_TEST_SETUP(resize_shape) {
4141

4242

4343
CUTEST_PARAMETRIZE(shapes, test_shapes_t, CUTEST_DATA(
44+
{0, {}, {}, {}, {1}, false, {0}}, // extend 0-D array
4445
{1, {5}, {3}, {2}, {10}, false, {5}}, // extend only
46+
{1, {0}, {1}, {2}, {1}, false, {0}}, // extend empty array
47+
{1, {0}, {100}, {7}, {2}, false, {0}}, // extend empty array with chunks/blocks set
48+
{2, {0, 0}, {100, 10}, {7, 3}, {2, 2}, false, {0, 0}}, // extend empty array with chunks/blocks larger than newshape
49+
{2, {0, 0}, {100, 10}, {7, 3}, {150, 160}, false, {0, 0}}, // extend empty array with chunks/blocks smaller than newshape
4550
{2, {20, 5}, {7, 5}, {3, 3}, {27, 10}, true, {14, 5}}, // extend only - start
4651
{2, {20, 10}, {7, 5}, {3, 5}, {10, 10}, false, {10, 10}}, // shrink only
4752
{2, {30, 20}, {8, 5}, {2, 2}, {22, 10}, true, {8, 5}}, // shrink only - start
@@ -52,7 +57,6 @@ CUTEST_TEST_SETUP(resize_shape) {
5257
{2, {50, 50}, {25, 13}, {8, 8}, {49, 51}, false, {49, 50}}, // shrink and extend
5358
{2, {143, 41}, {18, 13}, {7, 7}, {50, 50}, false, {50, 41}}, // shrink and extend
5459
{4, {10, 10, 5, 5}, {5, 7, 3, 3}, {2, 2, 1, 1}, {11, 20, 2, 2}, false, {10, 10, 2, 2}}, // shrink and extend
55-
5660
));
5761
}
5862

@@ -77,7 +81,7 @@ CUTEST_TEST_TEST(resize_shape) {
7781
shapes.chunkshape, shapes.blockshape, NULL, 0, NULL, 0);
7882

7983
int64_t buffersize = typesize;
80-
bool only_shrink = true;
84+
bool only_shrink = ctx->ndim == 0 ? false : true;
8185
for (int i = 0; i < ctx->ndim; ++i) {
8286
if (shapes.newshape[i] > shapes.shape[i]) {
8387
only_shrink = false;

tests/b2nd/test_b2nd_zeros.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CUTEST_TEST_SETUP(zeros) {
2121
CUTEST_PARAMETRIZE(shapes, _test_shapes, CUTEST_DATA(
2222
{0, {0}, {0}, {0}}, // 0-dim
2323
{1, {5}, {3}, {2}}, // 1-idim
24+
{1, {1}, {3}, {2}}, // chunks larger than shape
2425
{2, {20, 0}, {7, 0}, {3, 0}}, // 0-shape
2526
{2, {20, 10}, {7, 5}, {3, 5}}, // 0-shape
2627
{2, {14, 10}, {8, 5}, {2, 2}}, // general,

0 commit comments

Comments
 (0)