* @param axis The axis along which to repeat values.
     * @return Output array which has the same shape as a,
     *  except along the given axis.
     */
    public static PyMultiarray repeat(final PyObject oA, final PyObject oRepeats, int axis) {
        PyMultiarray a = PyMultiarray.asarray(oA), repeats = PyMultiarray
                .asarray(oRepeats);
        // Check axis and swap axis to zero.
        if (axis < 0) {
            axis += a.dimensions.length;
        }
        if (axis < 0 || axis >= a.dimensions.length) { throw Py
                .ValueError("illegal axis"); }
        a = PyMultiarray.swapAxes(a, 0, axis);
        // Check repeats argument, copy and cast to integer.
        repeats = PyMultiarray.array(repeats, 'i');
        if (repeats.dimensions.length != 1) { throw Py
                .ValueError("wrong number of dimensions"); }
        // Create the result array.
        final int[] dimensions = a.dimensions.clone();
        for (int i = dimensions[0] = 0; i < repeats.dimensions[0]; i++) {
            dimensions[0] += Array.getInt(repeats.data, i);
        }
        final PyMultiarray result = PyMultiarray.zeros(dimensions, a._typecode);
        int location = 0;
        for (int i = 0; i < repeats.dimensions[0]; i++) {
            final PyObject chunk = a.get(i);
            for (int j = 0; j < Array.getInt(repeats.data, i); j++) {
                result.set(location++, chunk);
            }
        }
        // Swap axis of result back to where it belongs and return.
        return PyMultiarray.swapAxes(result, 0, axis);
    }