Files
scgenerator/tests/test_grid.py
2023-09-26 09:52:44 +02:00

24 lines
583 B
Python

import numpy as np
import pytest
import scgenerator as sc
def test_scaling():
period = 2
nt = 512
t = sc.tspace(period, nt)
w = sc.wspace(t)
dt = t[1] - t[0]
assert w[1] - w[0] == pytest.approx(2 * np.pi / (period + dt))
assert dt == pytest.approx(period / (nt - 1))
def test_iwspace():
t = sc.tspace(dt=15.6, t_num=512)
assert sc.math.iwspace(sc.wspace(t)) == pytest.approx(t)
assert sc.math.iwspace(sc.wspace(t) + 4564568456.4) != pytest.approx(t)
assert sc.math.iwspace(sc.wspace(t) + 4564568456.4) == pytest.approx(t, rel=1e-3)