Пример #1
0
 def test_dataset(self):
     log_data = reader.linux_input_slack(self.log_data_dir, self.start_date,
                                         self.end_date)
     nicks, nick_same_list = nickTracker.nick_tracker(log_data)
     message_number_graph = network.message_number_graph(
         log_data, nicks, nick_same_list, False)
     expected_output = len(message_number_graph), int(
         message_number_graph.size('weight'))
     self.assertEqual(expected_output, self.expected_result)
Пример #2
0
    def test_message_number_graph(self, mock_rec_list_splice, mock_correctLastCharCR, mock_get_nick_sen_rec, mock_get_year_month_day,\
                         mock_get_nick_representative, mock_check_if_msg_line, mock_create_connected_nick_list, mock_to_graph):
        to_graph_ret = util.load_from_disk(
            current_directory + "/data/message_number_graph/to_graph")

        conn_list = list(connected_components(to_graph_ret))

        mock_to_graph.return_value = to_graph_ret
        mock_rec_list_splice.side_effect = util.load_from_disk(
            current_directory + "/data/message_number_graph/rec_list_splice")
        mock_create_connected_nick_list.return_value = util.load_from_disk(
            current_directory + "/data/message_number_graph/conn_comp_list")
        #mock_correct_last_char_list.side_effect = util.load_from_disk(current_directory + "/data/message_number_graph/correct_last_char_list")
        mock_check_if_msg_line.side_effect = util.load_from_disk(
            current_directory + "/data/message_number_graph/check_if_msg_line")
        mock_correctLastCharCR.side_effect = util.load_from_disk(
            current_directory + "/data/message_number_graph/correctLastCharCR")
        mock_get_nick_sen_rec.side_effect = util.load_from_disk(
            current_directory + "/data/message_number_graph/get_nick_sen_rec")
        #mock_extend_conversation_list.side_effect = util.load_from_disk(current_directory + "/data/message_number_graph/extend_conversation_list")
        mock_get_nick_representative.side_effect = util.load_from_disk(
            current_directory +
            "/data/message_number_graph/get_nick_representative")
        mock_get_year_month_day.side_effect = util.load_from_disk(
            current_directory +
            "/data/message_number_graph/get_year_month_day")

        capturedOutput = StringIO.StringIO()
        sys.stdout = capturedOutput

        ret = network.message_number_graph(self.log_data,
                                           self.nicks,
                                           self.nick_same_list,
                                           DAY_BY_DAY_ANALYSIS=False)

        sys.stdout = sys.__stdout__
        capturedOutput.close()

        mock_to_graph.assert_called_once_with(self.nick_same_list)
        mock_create_connected_nick_list.assert_called_once_with(conn_list)
        self.assertTrue(
            nx.is_isomorphic(
                ret,
                util.load_from_disk(
                    current_directory +
                    "/data/message_number_graph/aggregate_message_number_graph"
                )))
Пример #3
0
    def test_message_number_graph_day_analysis(self):

        capturedOutput = StringIO.StringIO()
        sys.stdout = capturedOutput

        ret = network.message_number_graph(self.log_data,
                                           self.nicks,
                                           self.nick_same_list,
                                           DAY_BY_DAY_ANALYSIS=True)
        expected_graph_list = util.load_from_disk(
            self.test_data_dir +
            "message_number_graph/message_number_day_list")

        sys.stdout = sys.__stdout__
        capturedOutput.close()

        self.assertTrue(nx.is_isomorphic(ret[0][0], expected_graph_list[0][0]))
Пример #4
0
    def test_message_number_graph(self):
        to_graph_ret = util.load_from_disk(self.test_data_dir +
                                           "message_number_graph/to_graph")

        conn_list = list(connected_components(to_graph_ret))

        capturedOutput = StringIO.StringIO()
        sys.stdout = capturedOutput

        ret = network.message_number_graph(self.log_data,
                                           self.nicks,
                                           self.nick_same_list,
                                           DAY_BY_DAY_ANALYSIS=False)

        sys.stdout = sys.__stdout__
        capturedOutput.close()

        self.assertTrue(
            nx.is_isomorphic(
                ret,
                util.load_from_disk(
                    self.test_data_dir +
                    "message_number_graph/aggregate_message_number_graph")))
Пример #5
0
config.CUTOFF_PERCENTILE = default_cutoff  #revert back to default

del truncated_rt, rt_cutoff_time, conv_len, conv_ref_time
del conv_len_curve_fit_parameters, resp_time_curve_fit_parameters, conv_ref_time_curve_fit_parameters
gc.collect()
print("conversation characteristics gc completed at: ",
      datetime.datetime.now(),
      file=exec_times_file)
exec_times_file.flush()

# ============== MESSAGE EXCHANGE GRAPH ANALYSIS =============
threshold = config.THRESHOLD_MESSAGE_NUMBER_GRAPH
config.THRESHOLD_MESSAGE_NUMBER_GRAPH = 0

message_number_graph = network.message_number_graph(log_data, nicks,
                                                    nick_same_list, False)
print("msg exchange graph with cutoff=0 generated at: ",
      datetime.datetime.now(),
      file=exec_times_file)
exec_times_file.flush()

saver.save_csv([["month", "users", "directed_messages"],
                [
                    "Jan-2013",
                    len(message_number_graph),
                    int(message_number_graph.size('weight'))
                ]], output_directory, "users_messages")

degree_anal_message_number = network.degree_analysis_on_graph(
    message_number_graph)
print("msg exchange graph node degree analysis completed at: ",