tests: adds tests without approximation for ewjn ezz
All checks were successful
gitea-physics/pyewjn/pipeline/head This commit looks good
All checks were successful
gitea-physics/pyewjn/pipeline/head This commit looks good
This commit is contained in:
parent
775e9ce3f0
commit
ff60ec4015
7
do.sh
7
do.sh
@ -18,7 +18,12 @@ test() {
|
||||
echo "I am ${FUNCNAME[0]}ing"
|
||||
poetry run flake8 pyewjn tests
|
||||
poetry run mypy pyewjn
|
||||
poetry run pytest
|
||||
poetry run pytest --benchmark-disable
|
||||
}
|
||||
|
||||
benchmark() {
|
||||
echo "I am ${FUNCNAME[0]}ing"
|
||||
poetry run pytest --benchmark-only
|
||||
}
|
||||
|
||||
htmlcov() {
|
||||
|
65
tests/noise/test_chi_nam_unapproximated.py
Normal file
65
tests/noise/test_chi_nam_unapproximated.py
Normal file
@ -0,0 +1,65 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import pyewjn.dielectric
|
||||
import pyewjn.noise.chi
|
||||
from pyewjn.baskets import CalculationParams
|
||||
|
||||
|
||||
cutoff_to_use = 5.4596e9
|
||||
|
||||
TOO_SLOW_REASON = "These tests are too slow and pretty unhelpful"
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=TOO_SLOW_REASON)
|
||||
@pytest.fixture
|
||||
def chi_zz_e_nam_unapproximated():
|
||||
params = CalculationParams(
|
||||
omega=1e9, v_f=2e6, omega_p=3.544907701811032e15, tau=1e-14, t_rel=0.99999
|
||||
)
|
||||
eps_l = pyewjn.dielectric.get_unapproximated_nam_dielectric(cutoff_to_use, params)
|
||||
return pyewjn.noise.chi.get_chi_zz_e(eps_l)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=TOO_SLOW_REASON)
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
# z chi_zz_e_nam_unapproximated(z)
|
||||
(1e-5, 4.07695673649665e6),
|
||||
(1e-6, 4.095895777068543e9),
|
||||
# (1e-7, 5.012885033150058e12), commenting this one out because it seems numerically too unstable
|
||||
# (1e-8, 1.441261982619894e16), commenting this one out because it seems numerically too unstable
|
||||
],
|
||||
)
|
||||
def test_chi_zz_e_nam_unapproximated(chi_zz_e_nam_unapproximated, test_input, expected):
|
||||
actual = chi_zz_e_nam_unapproximated(test_input)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual,
|
||||
expected,
|
||||
rtol=0.05,
|
||||
err_msg="chi_zz_e is inaccurate for nam_unapproximated case",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=TOO_SLOW_REASON)
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
# z chi_zz_e_nam_unapproximated(z)
|
||||
(1e-6, 4.095895777068543e9),
|
||||
],
|
||||
)
|
||||
def test_chi_zz_e_nam_unapproximated_benchmark(
|
||||
benchmark, chi_zz_e_nam_unapproximated, test_input, expected
|
||||
):
|
||||
actual = benchmark(chi_zz_e_nam_unapproximated, test_input)
|
||||
np.testing.assert_allclose(
|
||||
actual,
|
||||
expected,
|
||||
rtol=0.05,
|
||||
err_msg="chi_zz_e is inaccurate for nam_unapproximated case",
|
||||
verbose=True,
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user