private final static int shapeToNItems(final int[] shape) {
        int size = 1;
        for (final int element : shape) {
            if (element < 0) { throw Py
                    .ValueError("negative dimensions are not allowed"); }
            size *= element;
        }
        return size;
    }