[Numpy-discussion] Obscure code in concatenate code path?

Matthew Brett matthew.brett@gmail....
Thu Sep 13 05:12:40 CDT 2012


Hi,

While writing some tests for np.concatenate, I ran foul of this code:

    if (axis >= NPY_MAXDIMS) {
        ret = PyArray_ConcatenateFlattenedArrays(narrays, arrays, NPY_CORDER);
    }
    else {
        ret = PyArray_ConcatenateArrays(narrays, arrays, axis);
    }

in multiarraymodule.c

So, if the user passes an axis >= (by default) 32 the arrays to
concatenate get flattened, and must all have the same number of
elements (it turns out).  This seems obscure.  Obviously it is not
likely that someone would pass in an axis no >= 32 by accident, but if
they did, they would not get the result they expect.   Is there some
code-path that needs this?  Is there another way of doing it?

Best,

Matthew


More information about the NumPy-Discussion mailing list