def prod(vari, axis=None):
    """
    Product of the components of a shapeable quantity along a given axis.

    Args:
        vari (chaospy.poly.base.Poly, numpy.ndarray):
            Input data.
        axis (int):
            Axis over which the sum is taken. By default ``axis`` is None, and
            all elements are summed.

    Returns:
        (chaospy.poly.base.Poly, numpy.ndarray):
            Polynomial array with same shape as ``vari``, with the specified
            axis removed. If ``vari`` is an 0-d array, or ``axis`` is None,
            a (non-iterable) component is returned.

    Examples:
        >>> vari = cp.prange(3)
        >>> print(vari)
        [1, q0, q0^2]
        >>> print(cp.prod(vari))
        q0^3
    """
    if isinstance(vari, Poly):
        if axis is None:
            vari = chaospy.poly.shaping.flatten(vari)
            axis = 0

        vari = chaospy.poly.shaping.rollaxis(vari, axis)
        out = vari[0]
        for poly in vari[1:]:
            out = out*poly
        return out

    return np.prod(vari, axis)
Product of the components of a shapeable quantity along a given axis.

    Args:
        vari (chaospy.poly.base.Poly, numpy.ndarray):
            Input data.
        axis (int):
            Axis over which the sum is taken. By default ``axis`` is None, and
            all elements are summed.

    Returns:
        (chaospy.poly.base.Poly, numpy.ndarray):
            Polynomial array with same shape as ``vari``, with the specified
            axis removed. If ``vari`` is an 0-d array, or ``axis`` is None,
            a (non-iterable) component is returned.

    Examples:
        >>> vari = cp.prange(3)
        >>> print(vari)
        [1, q0, q0^2]
        >>> print(cp.prod(vari))
        q0^3