misc, tests

This commit is contained in:
2024-02-29 14:08:04 +01:00
parent d84138f668
commit 843b077850
4 changed files with 23 additions and 3 deletions

View File

@@ -10,4 +10,4 @@ from scgenerator.spectra import Spectrum, propagation, propagation_series
from scgenerator.physics import fiber, materials, plasma, pulse
from scgenerator.physics.units import PlotRange
from scgenerator.solver import SimulationResult, integrate, solve43
from scgenerator.cache import Cache
from scgenerator.cache import Cache, normalize_path

View File

@@ -141,6 +141,7 @@ class MultibarThread(Thread):
position=0,
colour="green",
desc=desc,
smoothing=0,
)
self.started = False
self.finished = False

View File

@@ -1,5 +1,5 @@
import scgenerator.cache as scc
from scgenerator.cache import Cache, methodcache, normalize_path
from scgenerator.cache import Cache, normalize_path
def test_io():
@@ -74,7 +74,6 @@ class Stuff:
def test_decorator():
cache = Cache("Test")
cache.compile_class(Stuff)
cache.delete()
call_count = 0
@@ -125,3 +124,11 @@ def test_normalize():
)
== "sdfl asdfk asd"
)
assert (
normalize_path(
"i=-1 [8.50e-07 9.00e-07 9.44e-07 1.01e-06 1.00e-06 1.05e-06 "
"1.10e-06 1.15e-06\n 1.20e-06 1.25e-06] [1.5e-08]nm.scbin"
)
== "i=-1 [8.50e-07 9.00e-07 9.44e-07 1.01e-06 1.00e-06 1.05e-06 1.10e-06 1.15e-06 "
"1.20e-06 1.25e-06] [1.5e-08]nm.scbin"
)

View File

@@ -85,3 +85,15 @@ def test_energy():
spec = Spectrum(spec, w, t)
assert np.all(spec.energy == np.trapz(abs2(np.fft.ifft(spec)), x=t, axis=-1))
assert spec.energy.shape == (3, 2)
def test_mask():
wl = 800e-9
bw = 50e-9
t = np.linspace(-1e-12, 1e-12, 4096)
w = wspace(t) + m_rads(wl)
spec = Spectrum(np.ones(4096) + 0j, w, t)
mased = spec.mask_wl(wl, bw)
above = mased.wl_int / mased.wl_int.max() - 0.5 >= 0
diff = spec.wl_disp[above].max() - spec.wl_disp[above].min()
assert diff == bw