Exemple #1
0
    def test_should_eval(self):
        metrics = Metrics('test')
        controller = BaseController(metrics, 110, 120, 130, 140)

        metrics.get = MagicMock(return_value=np.random.randint(100))
        assert not controller.should_eval()
        metrics.get.assert_called_once_with('step')

        metrics.get = MagicMock(return_value=np.random.randint(100) * 140)
        assert controller.should_eval()
        metrics.get.assert_called_once_with('step')
Exemple #2
0
    def test_save(self):
        metrics = Metrics('test')
        controller = BaseController(metrics, 110, 120, 130, 140)

        step = np.random.randint(100)
        metrics.get = MagicMock(return_value=step)
        metrics.save_model = MagicMock()
        controller.save()
        metrics.get.assert_called_once_with('step')
        metrics.save_model.assert_called_once_with(step)