def test_measure_with_several_measurers_check_returned(self): arch = MagicMock() arch.check_cost.return_value = ( None, np.array([ [-1, 0, 3], [3, 22, 0], [1, 2, 0.5], [-1, 0, 3], ]), ) model = Model(arch) (_, measures) = model.measure( np.array([]), np.array([ [1, -2, 3], [3, 2, 1], [3, 22, 0], [-1, 0, 3], ]), [ ProbsMeasurer(), ProbsMeasurer(), ProbsMeasurer(), ], ) self.assertEqual(measures, [3 / 4] * 3)
def test_measure_assert_returned_cost(self): arch = MagicMock() arch.check_cost.return_value = (0.5, None) model = Model(arch) cost, measures = model.measure(None, None, []) self.assertEqual(cost, 0.5) self.assertEqual(measures, [])
def test_measure_assert_returned_measures(self): arch = MagicMock() arch.check_cost.return_value = (None, None) model = Model(arch) measurer1 = MagicMock() measurer2 = MagicMock() measurer1.measure.return_value = 56.9 measurer2.measure.return_value = 70.1 (_, results) = model.measure(None, None, [measurer1, measurer2]) self.assertEqual(results, [56.9, 70.1])