def test_metric_setters_with_empty_params(self) -> None: """Test metric config setters with empty parameters.""" metric = Metric() metric.name = "TestMetric" metric.param = "" self.assertEqual(metric.name, "TestMetric") self.assertIsNone(metric.param)
def test_metric_setters(self) -> None: """Test metric config setters.""" metric = Metric() metric.name = "topk" metric.param = 1 self.assertEqual(metric.name, "topk") self.assertEqual(metric.param, 1)
def test_metric_serializer(self) -> None: """Test Metric config serializer.""" data = { "name": "topk", "param": 1, } metric = Metric(data) result = metric.serialize() self.assertDictEqual( result, { "topk": 1, }, )
def test_metric_constructor_from_yaml(self) -> None: """Test Metric config constructor.""" data = {"topk": 1} metric = Metric(data) self.assertEqual(metric.name, "topk") self.assertEqual(metric.param, 1)
def test_MSE_RMSE_MAE_metric_serializer(self) -> None: """Test MSE, RMSE and MAE metric config serializer.""" for metric_name in ["MSE", "RMSE", "MAE"]: data = { "name": metric_name, "param": True, } metric = Metric(data) result = metric.serialize() self.assertDictEqual( result, { f"{metric_name}": { "compare_label": True }, }, )
def test_metric_constructor(self) -> None: """Test Metric config constructor.""" data = { "name": "topk", "param": 1, } metric = Metric(data) self.assertEqual(metric.name, "topk") self.assertEqual(metric.param, 1)
def test_metric_constructor_defaults(self) -> None: """Test Metric config constructor defaults.""" metric = Metric() self.assertIsNone(metric.name) self.assertIsNone(metric.param)