|
1 | 1 | # coding: utf-8
|
2 | 2 | # 2019/12/17 @ tongshiwei
|
3 |
| - |
4 |
| -import json |
5 |
| -import pytest |
6 |
| -from longling import path_append |
7 |
| -from EduData.DataSet.EdNet.utils import Judgement |
8 |
| -from EduData.DataSet.EdNet.KnowledgeTracing import build_interactions, csv2interactions, select_n_most_active |
9 |
| - |
10 |
| - |
11 |
| -def test_utils(shared_data_dir): |
12 |
| - question_csv_path = path_append(shared_data_dir, "tests", "EdNet", "contents", "questions.csv") |
13 |
| - |
14 |
| - judgement = Judgement(question_csv_path) |
15 |
| - |
16 |
| - assert judgement.is_correct("q1", "b") is True |
17 |
| - assert judgement.is_correct("1", "c") is False |
18 |
| - |
19 |
| - with pytest.raises(ValueError): |
20 |
| - judgement.is_correct("q12000", "d") |
21 |
| - |
22 |
| - with pytest.raises(ValueError): |
23 |
| - judgement("q12000", "a") |
24 |
| - |
25 |
| - assert judgement("q1", "b") == (0, 1) |
26 |
| - |
27 |
| - |
28 |
| -def test_build_interactions(shared_data_dir): |
29 |
| - question_csv_path = path_append(shared_data_dir, "tests", "EdNet", "contents", "questions.csv") |
30 |
| - users_dir = path_append(shared_data_dir, "tests", "EdNet", "KT1") |
31 |
| - |
32 |
| - user_csv = path_append(users_dir, "u1.csv") |
33 |
| - |
34 |
| - judgement = Judgement(question_csv_path) |
35 |
| - |
36 |
| - interactions = csv2interactions(user_csv, judgement) |
37 |
| - |
38 |
| - assert interactions[0] == [5011, 0] |
39 |
| - |
40 |
| - tar = path_append(shared_data_dir, "tests", "EdNet", "KT1", "data", "kt.json") |
41 |
| - build_interactions(users_dir, question_csv_path, tar) |
42 |
| - |
43 |
| - with open(tar) as f: |
44 |
| - assert json.loads(f.readline())[0] == [5011, 0] |
45 |
| - assert len(json.loads(f.readline())) == 16 |
46 |
| - |
47 |
| - tar2 = path_append(tar, to_str=True) + ".%s" % 1 |
48 |
| - select_n_most_active(tar, tar2, 1) |
49 |
| - |
50 |
| - with open(tar2) as f: |
51 |
| - assert json.loads(f.readline())[0] == [5011, 0] |
| 3 | +# |
| 4 | +# import json |
| 5 | +# import pytest |
| 6 | +# from longling import path_append |
| 7 | +# from EduData.DataSet.EdNet.utils import Judgement |
| 8 | +# from EduData.DataSet.EdNet.KnowledgeTracing import build_interactions, csv2interactions, select_n_most_active |
| 9 | +# |
| 10 | +# |
| 11 | +# def test_utils(shared_data_dir): |
| 12 | +# question_csv_path = path_append(shared_data_dir, "tests", "EdNet", "contents", "questions.csv") |
| 13 | +# |
| 14 | +# judgement = Judgement(question_csv_path) |
| 15 | +# |
| 16 | +# assert judgement.is_correct("q1", "b") is True |
| 17 | +# assert judgement.is_correct("1", "c") is False |
| 18 | +# |
| 19 | +# with pytest.raises(ValueError): |
| 20 | +# judgement.is_correct("q12000", "d") |
| 21 | +# |
| 22 | +# with pytest.raises(ValueError): |
| 23 | +# judgement("q12000", "a") |
| 24 | +# |
| 25 | +# assert judgement("q1", "b") == (0, 1) |
| 26 | +# |
| 27 | +# |
| 28 | +# def test_build_interactions(shared_data_dir): |
| 29 | +# question_csv_path = path_append(shared_data_dir, "tests", "EdNet", "contents", "questions.csv") |
| 30 | +# users_dir = path_append(shared_data_dir, "tests", "EdNet", "KT1") |
| 31 | +# |
| 32 | +# user_csv = path_append(users_dir, "u1.csv") |
| 33 | +# |
| 34 | +# judgement = Judgement(question_csv_path) |
| 35 | +# |
| 36 | +# interactions = csv2interactions(user_csv, judgement) |
| 37 | +# |
| 38 | +# assert interactions[0] == [5011, 0] |
| 39 | +# |
| 40 | +# tar = path_append(shared_data_dir, "tests", "EdNet", "KT1", "data", "kt.json") |
| 41 | +# build_interactions(users_dir, question_csv_path, tar) |
| 42 | +# |
| 43 | +# with open(tar) as f: |
| 44 | +# assert json.loads(f.readline())[0] == [5011, 0] |
| 45 | +# assert len(json.loads(f.readline())) == 16 |
| 46 | +# |
| 47 | +# tar2 = path_append(tar, to_str=True) + ".%s" % 1 |
| 48 | +# select_n_most_active(tar, tar2, 1) |
| 49 | +# |
| 50 | +# with open(tar2) as f: |
| 51 | +# assert json.loads(f.readline())[0] == [5011, 0] |
0 commit comments