*   (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
     * @return The new multiarray
     */
    public static PyMultiarray fromFunction(final PyObject function, final PyObject shape) {
        final PyMultiarray index = PyMultiarray.indices(shape, '\0');
        final PyMultiarray result = PyMultiarray.zeros(shape);
        final PyMultiarray flatIndex = PyMultiarray.swapAxes(
                PyMultiarray.reshape(index, new int[] {
                        result.dimensions.length,
                        -1 }),
                0,
                1);
        final PyMultiarray flatResult = PyMultiarray.reshape(
                result,
                new int[] { -1 });
        PyObject[] args = new PyObject[0];
        final String[] keywords = new String[0];
        final Class<? extends PyObject[]> objectArray = args.getClass();
        for (int i = 0; i < flatResult.dimensions[0]; i++) {
            args = (PyObject[]) ((PyMultiarray) flatIndex.get(i)).tolist()
                    .__tojava__(objectArray);
            flatResult.set(i, function.__call__(args, keywords));
        }
        return result;
    }