Skip to content

Commit

Permalink
Add code coverage
Browse files Browse the repository at this point in the history
* add coverage for all lines within LossViewer.update_runtime()
  • Loading branch information
roomrys committed Mar 30, 2022
1 parent df905fd commit 592f01a
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/gui/test_monitor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 592f01a

Please sign in to comment.