pyewjn/tests/util/test_complex_integrate.py
Deepak Mallubhotla 071cd2503e
All checks were successful
gitea-physics/pyewjn/pipeline/head This commit looks good
feat!: Renames to pyewjn
2022-03-28 19:08:35 -05:00

31 lines
728 B
Python

import numpy as np
import pyewjn.util.complex_integrate
def test_complex_quad():
actual = pyewjn.util.complex_integrate.complex_quad(
lambda x: x**2 + 1j * x**3, 0, 6
)[0]
# int_1^6 dx x^2 + i x^3 should equal (1/3)6^3 + (i/4)6^4
np.testing.assert_almost_equal(
actual,
(6**3) / 3 + 1j * (6**4) / 4,
decimal=7,
err_msg="complex quadrature is broken",
verbose=True,
)
def test_complex_quadrature():
actual = pyewjn.util.complex_integrate.complex_quadrature(
lambda x: x**2 + 1j * x**3, 0, 6
)[0]
# int_1^6 dx x^2 + i x^3 should equal (1/3)6^3 + (i/4)6^4
np.testing.assert_almost_equal(
actual,
(6**3) / 3 + 1j * (6**4) / 4,
decimal=7,
err_msg="complex quadrature is broken",
verbose=True,
)