Skip to content

Commit

Permalink
adding tests for user skill reducer focus classes
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentM-GEG committed Nov 7, 2024
1 parent f86c56b commit 217d903
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 1 deletion.
5 changes: 4 additions & 1 deletion panoptes_aggregation/reducers/reducer_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def wrapper(argument, **kwargs):
if 'strategy' in kwargs:
kwargs_details['strategy'] = kwargs['strategy'].strip("\'")
if 'focus_classes' in kwargs:
kwargs_details['focus_classes'] = ast.literal_eval(kwargs['focus_classes'])
focus_classes = kwargs['focus_classes']
if isinstance(focus_classes, str):
focus_classes = ast.literal_eval(focus_classes)
kwargs_details['focus_classes'] = focus_classes

no_version = kwargs.pop('no_version', False)
if defaults_process is not None:
Expand Down
130 changes: 130 additions & 0 deletions panoptes_aggregation/tests/reducer_tests/test_user_skill_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,133 @@ def process(data):
processed_type='list',
test_name='TestOneToOneUserSkillReducer'
)


extracted_data = [
{
"1": 1,
"feedback": {
"strategy": "singleAnswerQuestion",
"true_answer": [
"1"
],
"agreement_score": 1
},
"aggregation_version": "4.1.0"
},
{
"7": 1,
"aggregation_version": "4.1.0"
},
{
"1": 1,
"feedback": {
"strategy": "singleAnswerQuestion",
"true_answer": [
"2"
],
"agreement_score": 0
},
"aggregation_version": "4.1.0"
},
{
"1": 1,
"aggregation_version": "4.1.0"
},
{
"1": 1,
"feedback": {
"strategy": "singleAnswerQuestion",
"true_answer": [
"1"
],
"agreement_score": 1
},
"aggregation_version": "4.1.0"
}
]

kwargs_extra_data = {
"relevant_reduction": [
{
"data": {
"difficulty": [
1
],
"aggregation_version": "4.1.0"
}
},
{
"data": {
"aggregation_version": "4.1.0"
}
},
{
"data": {
"difficulty": [
0
],
"aggregation_version": "4.1.0"
}
},
{
"data": {
"aggregation_version": "4.1.0"
}
},
{
"data": {
"difficulty": [
1
],
"aggregation_version": "4.1.0"
}
}
]
}


reduced_data = {
"classes": [
"1",
"2"
],
"confusion_simple": [
[
2,
0
],
[
1,
0
]
],
"weighted_skill": {
"1": 0.999999999999999,
"2": 0.0
},
"skill": {
"1": 1.0,
"2": 0.0
},
"count": {
"1": 2,
"2": 1
},
"mean_skill": 0.999999999999999,
"level_up": True
}

TestSubclassUserSkillReducer = ReducerTest(
user_skill_reducer,
process,
extracted_data,
extracted_data,
reduced_data,
'Test user skill reducer with class subsetting',
network_kwargs=kwargs_extra_data,
kwargs={'mode': 'one-to-one', 'strategy': 'all', 'skill_threshold': 0.2, 'count_threshold': 1, 'focus_classes': ["1"]},
add_version=False,
processed_type='list',
test_name='TestUserSkillReducer_SubsetClass'
)

0 comments on commit 217d903

Please sign in to comment.