def to_string(self, tabulate: bool = True) -> str:
     """
     Creates a multi-line human readable string from the given metrics.
     :param tabulate: If True then create a pretty printable table string.
     :return: Formatted metrics string
     """
     df = self.to_data_frame()
     return tabulate_dataframe(df) if tabulate else df.to_string(index=False)
def test_metrics_dict_to_string() -> None:
    """
    Test to make sure metrics dict is able to be stringified correctly
    """
    m = MetricsDict()
    m.add_metric("foo", 1.0)
    m.add_metric("bar", math.pi)
    info_df = pd.DataFrame(columns=MetricsDict.DATAFRAME_COLUMNS)
    info_df = info_df.append({MetricsDict.DATAFRAME_COLUMNS[0]: MetricsDict.DEFAULT_HUE_KEY,
                              MetricsDict.DATAFRAME_COLUMNS[1]: "foo: 1.0000, bar: 3.1416"}, ignore_index=True)
    assert m.to_string() == tabulate_dataframe(info_df)
    assert m.to_string(tabulate=False) == info_df.to_string(index=False)