def test_polynomials(self): for n, function, _, integral in polynomials(GaussQuadratures.orders[-1]): name = 'x^{}'.format(n) for order in GaussQuadratures.orders: if n > order / 2: continue Q = GaussQuadratures.iter_quadrature(order) ret = sum([function(p) * w for (p, w) in Q]) assert float_cmp(ret, integral), '{} integral wrong: {} vs {} (quadrature order {})'.format( name, integral, ret, order)
def test_polynomials(self): for n, function, _, integral in polynomials(GaussQuadratures.orders[-1]): name = f'x^{n}' for order in GaussQuadratures.orders: if n > order / 2: continue Q = GaussQuadratures.iter_quadrature(order) ret = sum([function(p) * w for (p, w) in Q]) assert float_cmp(ret, integral), \ f'{name} integral wrong: {integral} vs {ret} (quadrature order {order})'
def test_polynomials(self): for n, function, _, integral in polynomials( GaussQuadratures.orders[-1]): name = f'x^{n}' for order in GaussQuadratures.orders: if n > order / 2: continue Q = GaussQuadratures.iter_quadrature(order) ret = sum([function(p) * w for (p, w) in Q]) assert float_cmp(ret, integral), \ f'{name} integral wrong: {integral} vs {ret} (quadrature order {order})'