def test_string_log_value_from_fit_with_single_workspace(self):
        single_value_logs = [('sv_1', '5')]
        fake1 = create_test_workspace(ws_name='fake1',
                                      string_value_logs=single_value_logs)
        fit = FitInformation(mock.MagicMock(), 'func1',
                             [StaticWorkspaceWrapper(fake1.name(), fake1)],
                             mock.MagicMock(), mock.MagicMock())

        self.assertEqual(float(single_value_logs[0][1]),
                         fit.log_value(single_value_logs[0][0]))
    def test_time_series_log_value_from_fit_with_single_workspace_uses_time_average(
            self):
        time_series_logs = \
            [('ts_1', (("2000-05-01T12:00:00", 5.),
             ("2000-05-01T12:00:10", 20.),
             ("2000-05-01T12:05:00", 30.)))]
        fake1 = create_test_workspace('fake1', time_series_logs)
        fit = FitInformation(mock.MagicMock(), 'func1',
                             [StaticWorkspaceWrapper(fake1.name(), fake1)],
                             mock.MagicMock(), mock.MagicMock())

        time_average = (10 * 5 + 290 * 20) / 300.
        self.assertAlmostEqual(time_average, fit.log_value('ts_1'), places=6)
    def test_time_series_log_value_from_fit_with_multiple_workspaces_uses_average_of_time_average(
            self):
        time_series_logs1 = \
            [('ts_1', (("2000-05-01T12:00:00", 5.),
             ("2000-05-01T12:00:10", 20.),
             ("2000-05-01T12:05:00", 30.)))]
        fake1 = create_test_workspace('fake1', time_series_logs1)
        time_series_logs2 = \
            [('ts_1', (("2000-05-01T12:00:30", 10.),
             ("2000-05-01T12:01:45", 30.),
             ("2000-05-01T12:05:00", 40.)))]
        fake2 = create_test_workspace('fake2', time_series_logs2)
        fit = FitInformation(mock.MagicMock(), 'func1', [
            StaticWorkspaceWrapper(fake1.name(), fake1),
            StaticWorkspaceWrapper(fake2.name(), fake2)
        ], mock.MagicMock(), mock.MagicMock())

        time_average1 = (10 * 5 + 290 * 20) / 300.
        time_average2 = (75 * 10 + 195 * 30) / 270.
        all_average = 0.5 * (time_average1 + time_average2)
        self.assertAlmostEqual(all_average, fit.log_value('ts_1'), places=6)