From 592f01a2e39f62989bc52acfbc038ff6bc0a85e5 Mon Sep 17 00:00:00 2001 From: roomrys <38435167+roomrys@users.noreply.github.com> Date: Wed, 30 Mar 2022 12:19:40 -0700 Subject: [PATCH] Add code coverage * add coverage for all lines within LossViewer.update_runtime() --- tests/gui/test_monitor.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/gui/test_monitor.py b/tests/gui/test_monitor.py index 0eb85a8ee..51af0ca92 100644 --- a/tests/gui/test_monitor.py +++ b/tests/gui/test_monitor.py @@ -1,9 +1,35 @@ +from turtle import title from sleap.gui.widgets.monitor import LossViewer +from sleap import TrainingJobConfig -def test_monitor_release(qtbot): +def test_monitor_release(qtbot, min_centroid_model_path): win = LossViewer() win.show() + + # Ensure win loads config correctly + config = TrainingJobConfig.load_json(min_centroid_model_path, False) + win.reset(what="Model Type", config=config) + assert win.config.optimization.early_stopping.plateau_patience == 10 + + # Ensure all lines of update_runtime() are run error-free + win.is_running = True + win.t0 = 0 + # Enter "last_epoch_val_loss is not None" conditional + win.last_epoch_val_loss = win.config.optimization.early_stopping.plateau_min_delta + # Enter "penultimate_epoch_val_loss is not None" conditional + win.penultimate_epoch_val_loss = win.last_epoch_val_loss + win.mean_epoch_time_min = 0 + win.mean_epoch_time_sec = 10 + win.eta_ten_epochs_min = 2 + # Enter "epoch_in_plateau_flag" conditional + win.epoch_in_plateau_flag = True + win.epochs_in_plateau = 1 + # Enter "bes_val_x" conditional + win.best_val_x = 0 + win.best_val_y = win.last_epoch_val_loss + win.update_runtime() + win.close() # Make sure the first monitor released its zmq socket