Skip to content

Commit

Permalink
Update: related tests and linter issues fixed!
Browse files Browse the repository at this point in the history
  • Loading branch information
amindadgar committed Oct 17, 2023
1 parent fb682bc commit 1e4274d
Show file tree
Hide file tree
Showing 15 changed files with 249 additions and 473 deletions.
29 changes: 24 additions & 5 deletions tc_core_analyzer_lib/assess_engagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,23 @@ def compute(
# # # CONSISTENTLY ACTIVE # # #

all_consistent = assess_consistent(
all_active, w_i, act_param["CON_T_THR"], act_param["CON_O_THR"], WINDOW_D, all_consistent
all_active,
w_i,
act_param["CON_T_THR"],
act_param["CON_O_THR"],
WINDOW_D,
all_consistent,
)

# # # VITAL # # #

all_vital = assess_vital(
all_connected, w_i, act_param["VITAL_T_THR"], act_param["VITAL_O_THR"], WINDOW_D, all_vital
all_connected,
w_i,
act_param["VITAL_T_THR"],
act_param["VITAL_O_THR"],
WINDOW_D,
all_vital,
)

# # # STILL ACTIVE # # #
Expand Down Expand Up @@ -246,7 +256,10 @@ def compute(
rem_new_disengaged[str(w_i)],
all_disengaged_were_vital[str(w_i)],
) = assess_overlap(
all_new_disengaged, all_vital, w_i, (act_param["PAUSED_T_THR"] + 1) * WINDOW_D
all_new_disengaged,
all_vital,
w_i,
(act_param["PAUSED_T_THR"] + 1) * WINDOW_D,
)

# assess who of the remaining disengaged accounts
Expand All @@ -255,7 +268,10 @@ def compute(
rem_new_disengaged[str(w_i)],
all_disengaged_were_consistently_active[str(w_i)],
) = assess_overlap(
rem_new_disengaged, all_consistent, w_i, (act_param["PAUSED_T_THR"] + 1) * WINDOW_D
rem_new_disengaged,
all_consistent,
w_i,
(act_param["PAUSED_T_THR"] + 1) * WINDOW_D,
)

# assess who of the remaining disengaged accounts
Expand All @@ -264,7 +280,10 @@ def compute(
rem_new_disengaged[str(w_i)],
all_disengaged_were_newly_active[str(w_i)],
) = assess_overlap(
rem_new_disengaged, all_new_active, w_i, (act_param["PAUSED_T_THR"] + 1) * WINDOW_D
rem_new_disengaged,
all_new_active,
w_i,
(act_param["PAUSED_T_THR"] + 1) * WINDOW_D,
)
else:
all_disengaged_were_vital[str(w_i)] = set()
Expand Down
95 changes: 30 additions & 65 deletions tc_core_analyzer_lib/tests/integration/test_active_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,21 @@ def test_no_active():
# window index
w_i = 0

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active

# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2

# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

activities = [
DiscordActivity.Reaction,
Expand Down Expand Up @@ -165,38 +147,21 @@ def test_single_active():
WINDOW_D = 7
# window index
w_i = 0

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

activities = [
DiscordActivity.Reaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,21 @@ def test_all_active_fourteen_period():
so we should have the users as active for the interaction matrix
and not the window_d period here
"""
INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

analytics_length = 14
all_joined_day = dict(
Expand Down
46 changes: 15 additions & 31 deletions tc_core_analyzer_lib/tests/integration/test_consistently_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,21 @@ def test_two_consistently_active():
}
memberactivities = activity_dict.keys()

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

int_mat = {
DiscordActivity.Reply: np.zeros((acc_count, acc_count)),
Expand Down
46 changes: 15 additions & 31 deletions tc_core_analyzer_lib/tests/integration/test_disengaged_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,21 @@ def test_disengaged_members():
}
memberactivities = activity_dict.keys()

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

int_mat = {
DiscordActivity.Reply: np.zeros((acc_count, acc_count)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,21 @@ def test_disengaged_were_consistent():
}
memberactivities = activity_dict.keys()

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

int_mat = {
DiscordActivity.Reply: np.zeros((acc_count, acc_count)),
Expand Down
Loading

0 comments on commit 1e4274d

Please sign in to comment.