Exemplo n.º 1
0
    def test_response_time_high_cutoff_percentile(self):
        # this test assumes config.CUTOFF_TIME_STRATEGY = "TWO_SIGMA"

        cutoff_percentile = 5.0
        expected_resp_time = util.load_from_disk(current_directory +
                                                 "/data/truncated_rt_5percent")
        expected_cutoff_time = 2
        resp_time, cutoff_time = channel.response_time(self.log_data,
                                                       self.nicks,
                                                       self.nick_same_list,
                                                       cutoff_percentile)
        assert resp_time == expected_resp_time, \
                "Error in computing response time with 5% cutoff percentile."
        assert cutoff_time == expected_cutoff_time, \
                "Error in computing RT cutoff with 5% cutoff percentile."

        cutoff_percentile = 10.0
        expected_resp_time = util.load_from_disk(
            current_directory + "/data/truncated_rt_10percent")
        expected_cutoff_time = 2
        resp_time, cutoff_time = channel.response_time(self.log_data,
                                                       self.nicks,
                                                       self.nick_same_list,
                                                       cutoff_percentile)
        assert resp_time == expected_resp_time, \
                "Error in computing response time with 10% cutoff percentile."
        assert cutoff_time == expected_cutoff_time, \
                "Error in computing RT cutoff with 10% cutoff percentile."
Exemplo n.º 2
0
    def test_response_time_low_cutoff_percentile(self):
        # this test assumes config.CUTOFF_TIME_STRATEGY = "TWO_SIGMA"

        cutoff_percentile = 0.0
        expected_resp_time = util.load_from_disk(self.current_directory + "/data/resp_time")
        expected_cutoff_time = 2
        resp_time, cutoff_time = channel.response_time(self.log_data, self.nicks,
                                          self.nick_same_list, cutoff_percentile)
        self.assertEqual(resp_time, expected_resp_time, \
                "Error in computing response time with 0% cutoff percentile.")
        self.assertEqual(cutoff_time, expected_cutoff_time, \
                "Error in computing RT cutoff with 0% cutoff percentile.")

        cutoff_percentile = 1.0
        expected_resp_time = util.load_from_disk(self.current_directory + "/data/truncated_rt_1percent")
        expected_cutoff_time = 2
        resp_time, cutoff_time = channel.response_time(self.log_data, self.nicks,
                                          self.nick_same_list, cutoff_percentile)
        self.assertEqual(resp_time, expected_resp_time, \
                "Error in computing response time with 1% cutoff percentile.")
        self.assertEqual(cutoff_time, expected_cutoff_time, \
                "Error in computing RT cutoff with 1% cutoff percentile.")
Exemplo n.º 3
0
del bin_matrix, total_messages, data
gc.collect()

print("msg bins gc completed at: ",
      datetime.datetime.now(),
      file=exec_times_file)
exec_times_file.flush()

# ============== CONVERSATION CHARACTERISTICS =============
default_cutoff = config.CUTOFF_PERCENTILE
#percentiles = [0, 1, 5, 10, 20]
percentiles = [1]

for cutoff in percentiles:
    config.CUTOFF_PERCENTILE = cutoff
    truncated_rt, rt_cutoff_time = channel.response_time(
        log_data, nicks, nick_same_list, config.CUTOFF_PERCENTILE)
    conv_len, conv_ref_time = channel.conv_len_conv_refr_time(
        log_data, nicks, nick_same_list, rt_cutoff_time,
        config.CUTOFF_PERCENTILE)
    saver.save_csv(conv_len, output_directory,
                   "conv_len-cutoff-" + str(cutoff))
    saver.save_csv(truncated_rt, output_directory,
                   "resp_time-cutoff-" + str(cutoff))
    saver.save_csv(conv_ref_time, output_directory,
                   "conv_ref_time-cutoff-" + str(cutoff))
    conv_len_curve_fit_parameters = vis.exponential_curve_fit_and_plot(
        conv_len, output_directory, "conv_len_cutoff" + str(cutoff))
    resp_time_curve_fit_parameters = vis.exponential_curve_fit_and_plot(
        truncated_rt, output_directory, "resp_time_cutoff" + str(cutoff))
    conv_ref_time_curve_fit_parameters = vis.exponential_curve_fit_and_plot_x_shifted(
        conv_ref_time, output_directory, "conv_ref_time_cutoff" + str(cutoff))