Example #1
0
 def test_non_matching_stats_keys(self):
     r1 = result.Result()
     r1.add_stats({"bla": 1., "blub": 2.})
     r2 = result.Result()
     r2.add_stats({"foo": 1., "bar": 2.})
     with self.assertRaises(result.ResultException):
         result.merge_results([r1, r2])
Example #2
0
 def test_non_matching_np_arrays_keys(self):
     r1 = result.Result()
     r1.add_np_array("test", np.array([]))
     r1.add_np_array("test_2", np.array([]))
     r2 = result.Result()
     r2.add_np_array("test", np.array([]))
     with self.assertRaises(result.ResultException):
         result.merge_results([r1, r2])
Example #3
0
 def test_merge_strategy_average(self):
     r1 = result.Result()
     r1.add_np_array("test", np.array([1., 2., 3.]))
     r1.add_stats({"bla": 1., "blub": 2.})
     r2 = result.Result()
     r2.add_np_array("test", np.array([0., 0., 0.]))
     r2.add_stats({"bla": 0., "blub": 0.})
     merged = result.merge_results([r1, r2])
     self.assertTrue(
         np.array_equal(merged.np_arrays["test"], np.array([0.5, 1., 1.5])))
     self.assertEqual(merged.stats, {"bla": 0.5, "blub": 1.})
Example #4
0
def load_results_as_dataframe(result_files: typing.Iterable[str],
                              use_filenames: bool = False,
                              merge: bool = False) -> pd.DataFrame:
    if merge:
        results = [file_interface.load_res_file(f) for f in result_files]
        return pandas_bridge.result_to_df(merge_results(results))

    df = pd.DataFrame()
    for result_file in result_files:
        result = file_interface.load_res_file(result_file)
        name = result_file if use_filenames else None
        df = pd.concat([df, pandas_bridge.result_to_df(result, name)],
                       axis="columns")
    return df
Example #5
0
def load_results_as_dataframe(result_files, use_filenames=False, merge=False):
    import pandas as pd
    from evo.tools import pandas_bridge
    from evo.tools import file_interface

    if merge:
        from evo.core.result import merge_results
        results = [file_interface.load_res_file(f) for f in result_files]
        return pandas_bridge.result_to_df(merge_results(results))

    df = pd.DataFrame()
    for result_file in result_files:
        result = file_interface.load_res_file(result_file)
        name = result_file if use_filenames else None
        df = pd.concat([df, pandas_bridge.result_to_df(result, name)],
                       axis="columns")
    return df