Ejemplo n.º 1
0
 def test_parses_from_dict_1D_distribution(self) -> None:
     """Check that a 1D distribution metric can be parsed from its dict representation."""
     parsed_metric = GtsfmMetric.parse_from_dict(
         self._metric_dict_quartiles)
     self.assertEqual(parsed_metric.name, "foo_metric")
     self.assertEqual(parsed_metric.plot_type, GtsfmMetric.PlotType.BOX)
     self.assertIn("quartiles", parsed_metric.summary)
     self.assertIn("full_data",
                   parsed_metric.get_metric_as_dict()[parsed_metric.name])
Ejemplo n.º 2
0
 def test_parses_from_dict_no_full_data(self) -> None:
     """Check that a 1D distribution metric can be parsed from dict without full data field."""
     parsed_metric = GtsfmMetric.parse_from_dict(self._metric_dict_no_data)
     self.assertEqual(parsed_metric.name, "bar_metric")
     self.assertEqual(parsed_metric.plot_type,
                      GtsfmMetric.PlotType.HISTOGRAM)
     self.assertIn("histogram", parsed_metric.summary)
     self.assertNotIn(
         "full_data",
         parsed_metric.get_metric_as_dict()[parsed_metric.name])
Ejemplo n.º 3
0
 def test_parses_from_dict_1D_distribution_histogram(self) -> None:
     """Check that a 1D distribution metric with histogram summary can be parsed from dict."""
     parsed_metric = GtsfmMetric.parse_from_dict(
         self._metric_dict_histogram)
     self.assertEqual(parsed_metric.name, "bar_metric")
     self.assertEqual(parsed_metric.plot_type,
                      GtsfmMetric.PlotType.HISTOGRAM)
     self.assertIn("histogram", parsed_metric.summary)
     self.assertIn("full_data",
                   parsed_metric.get_metric_as_dict()[parsed_metric.name])
Ejemplo n.º 4
0
 def test_parses_from_dict_scalar(self) -> None:
     """Check that a scalar metric can be parsed from its dict representation."""
     scalar_metric_dict = {"foo_metric": 2}
     parsed_metric = GtsfmMetric.parse_from_dict(scalar_metric_dict)
     self.assertEqual(parsed_metric.name, "foo_metric")
     np.testing.assert_equal(parsed_metric.data, 2)