From 60f668c09e72cc6bdd480dad68e83669456298b7 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 5 Mar 2024 16:01:07 +0330 Subject: [PATCH] feat: zeroing self interactions! --- .../analysis/compute_interaction_matrix_discord.py | 11 +++++++++-- discord_analyzer/analysis/compute_member_activity.py | 5 ----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/discord_analyzer/analysis/compute_interaction_matrix_discord.py b/discord_analyzer/analysis/compute_interaction_matrix_discord.py index da0b08d..fc911bb 100644 --- a/discord_analyzer/analysis/compute_interaction_matrix_discord.py +++ b/discord_analyzer/analysis/compute_interaction_matrix_discord.py @@ -6,10 +6,10 @@ # Author Ene SS Rawa / Tjitse van der Molen from typing import Any import copy -from tc_core_analyzer_lib.utils.activity import DiscordActivity from discord_analyzer.DB_operations.mongodb_access import DB_access from discord_analyzer.DB_operations.mongodb_query import MongodbQuery -from numpy import ndarray +from tc_core_analyzer_lib.utils.activity import DiscordActivity +from numpy import ndarray, diag_indices_from from .utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, @@ -94,6 +94,13 @@ def compute_interaction_matrix_discord( acc_names=acc_names, activities=[activity], ) + # a person interacting to themselves is not counted as activity + if activity in [ + DiscordActivity.Reply, + DiscordActivity.Reaction, + DiscordActivity.Mention, + ]: + int_mat[activity][diag_indices_from(int_mat[activity])] = 0 return int_mat diff --git a/discord_analyzer/analysis/compute_member_activity.py b/discord_analyzer/analysis/compute_member_activity.py index d214c58..7498e92 100644 --- a/discord_analyzer/analysis/compute_member_activity.py +++ b/discord_analyzer/analysis/compute_member_activity.py @@ -289,11 +289,6 @@ def compute_member_activity( acc_names, date_list_w_str, channels, db_access ) - # # for each int_mat type - # for key in list(int_mat.keys()): - # # remove interactions with self - # int_mat[key][np.diag_indices_from(int_mat[key])] = 0 - # assess engagement (graph_out, *activity_dict) = assess_engagment.compute( int_mat=int_mat,