kopia lustrzana https://github.com/corrscope/corrscope
Fix unit tests
rodzic
a7b1c06114
commit
acffc1a55e
|
@ -22,7 +22,7 @@ def test_channel_subsampling(
|
|||
render_width_ratio: int,
|
||||
mocker: MockFixture
|
||||
):
|
||||
""" Ensure nsamp and trigger/render subsampling are computed correctly. """
|
||||
""" Ensure window_samp and trigger/render subsampling are computed correctly. """
|
||||
|
||||
ovgenpy.ovgenpy.PRINT_TIMESTAMP = False # Cleanup Hypothesis testing logs
|
||||
|
||||
|
@ -50,34 +50,34 @@ def test_channel_subsampling(
|
|||
)
|
||||
channel = Channel(ccfg, cfg)
|
||||
|
||||
# Ensure channel.nsamp, trigger_subsampling, render_subsampling are correct.
|
||||
# Ensure channel.window_samp, trigger_subsampling, render_subsampling are correct.
|
||||
ideal_nsamp = pytest.approx(
|
||||
round(cfg.render_width_s * channel.wave.smp_s / subsampling), 1)
|
||||
|
||||
assert channel.nsamp == ideal_nsamp
|
||||
assert channel.window_samp == ideal_nsamp
|
||||
assert channel.trigger_subsampling == subsampling * trigger_width_ratio
|
||||
assert channel.render_subsampling == subsampling * render_width_ratio
|
||||
|
||||
# Ensure trigger uses channel.nsamp and trigger_subsampling.
|
||||
# Ensure trigger uses channel.window_samp and trigger_subsampling.
|
||||
trigger = channel.trigger
|
||||
assert trigger._nsamp == channel.nsamp
|
||||
assert trigger._tsamp == channel.window_samp
|
||||
assert trigger._subsampling == channel.trigger_subsampling
|
||||
|
||||
# Ensure ovgenpy calls render using channel.nsamp and render_subsampling.
|
||||
# Ensure ovgenpy calls render using channel.window_samp and render_subsampling.
|
||||
ovgen = Ovgen(cfg)
|
||||
renderer = mocker.patch.object(Ovgen, '_load_renderer').return_value
|
||||
ovgen.play()
|
||||
|
||||
# Inspect arguments to wave.get_around()
|
||||
(_sample, _region_nsamp, _subsampling), kwargs = wave.get_around.call_args
|
||||
assert _region_nsamp == channel.nsamp
|
||||
assert _region_nsamp == channel.window_samp
|
||||
assert _subsampling == channel.render_subsampling
|
||||
|
||||
# Inspect arguments to renderer.render_frame()
|
||||
# datas: List[np.ndarray]
|
||||
(datas,), kwargs = renderer.render_frame.call_args
|
||||
render_data = datas[0]
|
||||
assert len(render_data) == channel.nsamp
|
||||
assert len(render_data) == channel.window_samp
|
||||
|
||||
|
||||
# line_color is tested in test_renderer.py
|
||||
|
|
|
@ -21,8 +21,7 @@ def cfg(request):
|
|||
|
||||
# I regret adding the nsamp_frame parameter. It makes unit tests hard.
|
||||
|
||||
NSAMP_FRAME = round(48000 / 60)
|
||||
|
||||
FPS = 60
|
||||
|
||||
def test_trigger(cfg: CorrelationTriggerConfig):
|
||||
wave = Wave(None, 'tests/impulse24000.wav')
|
||||
|
@ -31,7 +30,7 @@ def test_trigger(cfg: CorrelationTriggerConfig):
|
|||
plot = False
|
||||
x0 = 24000
|
||||
x = x0 - 500
|
||||
trigger = cfg(wave, 4000, subsampling=1, nsamp_frame=NSAMP_FRAME)
|
||||
trigger = cfg(wave, 4000, subsampling=1, fps=FPS)
|
||||
|
||||
if plot:
|
||||
BIG = 0.95
|
||||
|
@ -64,8 +63,8 @@ def test_trigger_subsampling(cfg: CorrelationTriggerConfig):
|
|||
iters = 5
|
||||
x0 = 24000
|
||||
subsampling = 4
|
||||
trigger = cfg(wave, nsamp=100, subsampling=subsampling, nsamp_frame=NSAMP_FRAME)
|
||||
# real nsamp = nsamp*subsampling
|
||||
trigger = cfg(wave, tsamp=100, subsampling=subsampling, fps=FPS)
|
||||
# real window_samp = window_samp*subsampling
|
||||
# period = 109
|
||||
|
||||
for i in range(1, iters):
|
||||
|
@ -100,8 +99,8 @@ def test_trigger_subsampling_edges(cfg: CorrelationTriggerConfig):
|
|||
|
||||
iters = 5
|
||||
subsampling = 4
|
||||
trigger = cfg(wave, nsamp=100, subsampling=subsampling, nsamp_frame=NSAMP_FRAME)
|
||||
# real nsamp = nsamp*subsampling
|
||||
trigger = cfg(wave, tsamp=100, subsampling=subsampling, fps=FPS)
|
||||
# real window_samp = window_samp*subsampling
|
||||
# period = 109
|
||||
|
||||
trigger.get_trigger(0)
|
||||
|
|
Ładowanie…
Reference in New Issue