Skip to content

Commit e78e418

Browse files
committed
added variants generator
1 parent 0ddd0f3 commit e78e418

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ cmake-build-release
44
cmake-build-debug
55
.idea/
66
.vscode/
7+
scripts/variants.csv
8+
scripts/variants.xlsx

scripts/variants_generation.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import numpy as np
2+
from sklearn.utils import shuffle
3+
import csv
4+
from xlsxwriter.workbook import Workbook
5+
6+
NUM_TASKS = 3
7+
NUM_STUDENTS = 25
8+
NUM_VARIANTS = 27
9+
csvfile = 'variants.csv'
10+
11+
list_of_tasks = []
12+
str_of_print = ""
13+
str_of_headers = ""
14+
for i in range(NUM_TASKS):
15+
list_of_variants = []
16+
shuffled_list_of_variants = []
17+
for j in range(int(NUM_STUDENTS / NUM_VARIANTS) + 1):
18+
list_of_variants.append(np.arange(NUM_VARIANTS) + 1)
19+
for variant in list_of_variants:
20+
shuffled_list_of_variants.append(shuffle(variant))
21+
result_variants = np.concatenate(shuffled_list_of_variants)
22+
list_of_tasks.append(result_variants[:NUM_STUDENTS])
23+
str_of_print += '%d,'
24+
str_of_headers += 'Task ' + str(i + 1) + ','
25+
str_of_print = str_of_print[:-1]
26+
str_of_headers = str_of_headers[:-1]
27+
28+
np.savetxt(csvfile, np.dstack(list_of_tasks)[0], str_of_print, header=str_of_headers)
29+
30+
workbook = Workbook(csvfile[:-4] + '.xlsx')
31+
worksheet = workbook.add_worksheet()
32+
with open(csvfile, 'rt', encoding='utf8') as f:
33+
reader = csv.reader(f)
34+
for r, row in enumerate(reader):
35+
for c, col in enumerate(row):
36+
worksheet.write(r, c, col)
37+
workbook.close()

0 commit comments

Comments
 (0)