Skip to content

Commit 44521fb

Browse files
Fix minor bug
1 parent 8d2a896 commit 44521fb

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

autokattis/api/databasemanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, user):
1111
name = option.text.strip()
1212
if val and name: self.LANGUAGES[val] = name
1313
for val, name in [*self.LANGUAGES.items()]:
14-
self.LANGUAGES[name] = val
14+
self.LANGUAGES[name] = self.LANGUAGES[val] = val
1515
print('[database] Listed all available languages!', flush=True)
1616

1717
self.COUNTRIES = {}

autokattis/api/nuskattis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def stats(self, languages=None, *bc_args):
354354
params = {
355355
'page': 0,
356356
'status': 'AC',
357-
'language': language
357+
'language': self.get_database().get_languages().get(language)
358358
}
359359
data = {}
360360
with ThreadPoolExecutor(max_workers=self.get_max_workers()) as executor:
@@ -467,7 +467,7 @@ def offerings(self, course_id):
467467
name, end_date = [truncate_spaces(column.text.strip()) for column in columns]
468468
link, _ = [column.find('a') for column in columns]
469469
data.append({
470-
'name': name,
470+
'name': name.replace('\n', ''),
471471
'end_date': end_date.split()[1][:-1],
472472
'link': self.get_base_url() + link.get('href')
473473
})

autokattis/api/openkattis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,12 @@ def plot_problems(self, filepath=None, show_solved=True, show_partial=True, show
211211
categories = set(df.category)
212212

213213
hue_order = [enum_to_title(c) for c in [DifficultyColor.N_A, DifficultyColor.HARD, DifficultyColor.MEDIUM, DifficultyColor.EASY] if enum_to_title(c) in categories]
214-
palette = {enum_to_title(c):c.value for c in [DifficultyColor.EASY, DifficultyColor.MEDIUM, DifficultyColor.HARD, DifficultyColor.NA] if c in categories}
214+
palette = {enum_to_title(c):c.value for c in [DifficultyColor.EASY, DifficultyColor.MEDIUM, DifficultyColor.HARD, DifficultyColor.N_A] if enum_to_title(c) in categories}
215215

216216
diff_lo = math.floor(min([d for d in df.difficulty if d], default=0))
217217
diff_hi = math.ceil(max([d for d in df.difficulty if d], default=0))
218218

219+
plt.clf()
219220
hist = sns.histplot(data=df, x='difficulty', hue='category', multiple='stack', bins=[i/10 for i in range(10*diff_lo, 10*diff_hi+1)], hue_order=hue_order, palette=palette)
220221
hist.set(title=f'Solved Kattis Problems by {self.get_username()} ({df.shape[0]})', xlabel='Difficulty')
221222
plt.legend(title='Category', loc='upper right', labels=hue_order[::-1])
@@ -505,7 +506,7 @@ def stats(self, languages=None, *bc_args):
505506
params = {
506507
'page': 0,
507508
'status': 'AC',
508-
'language': language
509+
'language': self.get_database().get_languages().get(language)
509510
}
510511
data = {}
511512
with ThreadPoolExecutor(max_workers=self.get_max_workers()) as executor:

test/nuskattis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
test('nus_courses', kt.courses, {})
2222

23-
test('nus_offerings_valid_1', kt.courses, {'course_id': 'CS2040'})
24-
test('nus_offerings_valid_2', kt.courses, {'course_id': 'CS3233'})
25-
test('nus_offerings_invalid', kt.courses, {'course_id': 'idk'})
23+
test('nus_offerings_valid_1', kt.offerings, {'course_id': 'CS2040'})
24+
test('nus_offerings_valid_2', kt.offerings, {'course_id': 'CS3233'})
25+
test('nus_offerings_invalid', kt.offerings, {'course_id': 'idk'})
2626

27-
test('nus_assignments_courseid_guessed', kt.assignments, {'offering_id': 'CS3233_S2_AY2223'})
27+
test('nus_assignments_courseid_guessed', kt.assignments, {'offering_id': 'CS2040_S1_AY2425'})
2828
test('nus_assignments_courseid_given', kt.assignments, {'offering_id': 'CS3233_S2_AY2223', 'course_id': 'CS3233'})

test/openkattis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
kt = Kattis(USER, PASSWORD)
66
kt = OpenKattis(USER, PASSWORD)
77

8-
test('open_problems_solved_ldm', kt.problems, {})
9-
test('open_problems_solved_fdm', kt.problems, {'low_detail_mode': False})
10-
test('open_problems_all_ldm', kt.problems, {'show_tried': True, 'show_untried': True})
11-
test('open_problems_all_fdm', kt.problems, {'show_tried': True, 'show_untried': True, 'low_detail_mode': False})
8+
test('open_problems_solved_fdm', kt.problems, {})
9+
test('open_problems_solved_ldm', kt.problems, {'low_detail_mode': True})
10+
test('open_problems_all_fdm', kt.problems, {'show_tried': True, 'show_untried': True})
11+
test('open_problems_all_ldm', kt.problems, {'show_tried': True, 'show_untried': True, 'low_detail_mode': True})
1212

1313
test('open_plot_problems_solved_nofile', kt.plot_problems, {})
1414
test('open_plot_problems_solved_file', kt.plot_problems, {'filepath': 'plot1.png'})

test/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ def test(title, fn, kwargs, csv=True):
2020
start = time.perf_counter()
2121
try:
2222
ret = fn(**kwargs)
23-
print(df:=ret.to_df())
24-
if csv: df.to_csv(f'{title}.csv', index=False)
23+
if ret != None:
24+
print(df:=ret.to_df())
25+
if csv: df.to_csv(f'{title}.csv', index=False)
2526
print(f'Time taken: {round(time.perf_counter()-start, 4)}s')
2627
print(f'[{bcolors.OKGREEN}OK{bcolors.ENDC}] {fn.__qualname__}:{title}')
2728
except Exception as e:
2829
print(f'{type(e).__name__}: {e}')
2930
print(f'Time taken: {round(time.perf_counter()-start, 4)}s')
30-
print(f'[{bcolors.FAIL}FAIL{bcolors.ENDC}] {fn.__qualname__}:{title}')
31+
print(f'[{bcolors.FAIL}FAIL{bcolors.ENDC}] {fn.__qualname__}:{title}')

0 commit comments

Comments
 (0)