(pts)
return np.array(
        [
            gauss_legendre(k).integrate(
                # Normalized Lagrange polynomial: Degree n-1, 0 at all x_j, 1 at x_i.
                lambda x: np.prod(
                    [(x - pts[j]) / (pts[i] - pts[j]) for j in range(n) if j != i],
                    axis=0,
                ).reshape(np.asarray(x).shape),
                np.array([-1, 1]),
            )
            for i in range(n)
        ]
    )
Given a number of points in [-1, 1], according to

        T.N.L. Patterson,
        On some Gauss and Lobatto based integration formulae,
        Math. Comp. 22 (1968), 877-881,
        https://doi.org/10.1090/S0025-5718-68-99865-7,

    one can compute the corresponding weights. One reads there:

    > Thus the weights of an n-point integration formula [...] are given by
    >
    >     omega_i = int_{-1}^{1} L_i(x) dx,
    >
    > (where L_i is the Lagrange polynomial for the point x_i). These weights can be
    > evaluated exactly in a numerically stable fashion using a Gauss formula with n/2
    > points when n is even and (n + 1)/2 points > when n is odd.
Given a number of points in [-1, 1], according to
Given a number of points in [ - 1 1 ] according to
def _get_weights(pts):
    """Given a number of points in [-1, 1], according to

        T.N.L. Patterson,
        On some Gauss and Lobatto based integration formulae,
        Math. Comp. 22 (1968), 877-881,
        https://doi.org/10.1090/S0025-5718-68-99865-7,

    one can compute the corresponding weights. One reads there:

    > Thus the weights of an n-point integration formula [...] are given by
    >
    >     omega_i = int_{-1}^{1} L_i(x) dx,
    >
    > (where L_i is the Lagrange polynomial for the point x_i). These weights can be
    > evaluated exactly in a numerically stable fashion using a Gauss formula with n/2
    > points when n is even and (n + 1)/2 points > when n is odd.
    """
    n = len(pts)

    # Gauss-Legendre of order k integrates polynomials of degree 2*k-1 exactly. L has
    # degree n-1, so k needs to be n/2 if n is even, and (n+1)/2 if n is odd.
    k = (n // 2) - 1 if n % 2 == 0 else (n + 1) // 2
    return np.array(
        [
            gauss_legendre(k).integrate(
                # Normalized Lagrange polynomial: Degree n-1, 0 at all x_j, 1 at x_i.
                lambda x: np.prod(
                    [(x - pts[j]) / (pts[i] - pts[j]) for j in range(n) if j != i],
                    axis=0,
                ).reshape(np.asarray(x).shape),
                np.array([-1, 1]),
            )
            for i in range(n)
        ]
    )
def _get_weights ( pts ) : n = len ( pts ) # Gauss-Legendre of order k integrates polynomials of degree 2*k-1 exactly. L has # degree n-1, so k needs to be n/2 if n is even, and (n+1)/2 if n is odd. k = ( n // 2 ) - 1 if n % 2 == 0 else ( n + 1 ) // 2 return np . array ( [ gauss_legendre ( k ) . integrate ( # Normalized Lagrange polynomial: Degree n-1, 0 at all x_j, 1 at x_i. lambda x : np . prod ( [ ( x - pts [ j ] ) / ( pts [ i ] - pts [ j ] ) for j in range ( n ) if j != i ] , axis = 0 , ) . reshape ( np . asarray ( x ) . shape ) , np . array ( [ - 1 , 1 ] ) , ) for i in range ( n ) ] )