kattis-cli 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kattis_cli/main.py +1 -1
- kattis_cli/test_solution.py +22 -18
- kattis_cli/utils/utility.py +12 -4
- {kattis_cli-1.0.4.dist-info → kattis_cli-1.0.5.dist-info}/METADATA +1 -1
- {kattis_cli-1.0.4.dist-info → kattis_cli-1.0.5.dist-info}/RECORD +8 -8
- {kattis_cli-1.0.4.dist-info → kattis_cli-1.0.5.dist-info}/LICENSE +0 -0
- {kattis_cli-1.0.4.dist-info → kattis_cli-1.0.5.dist-info}/WHEEL +0 -0
- {kattis_cli-1.0.4.dist-info → kattis_cli-1.0.5.dist-info}/entry_points.txt +0 -0
kattis_cli/main.py
CHANGED
|
@@ -7,7 +7,7 @@ build.sh script copies the contents of this file to main.py.
|
|
|
7
7
|
Change the __version__ to match in pyproject.toml
|
|
8
8
|
Has to be higher than the pypi version.
|
|
9
9
|
"""
|
|
10
|
-
__version__ = '1.0.
|
|
10
|
+
__version__ = '1.0.5'
|
|
11
11
|
|
|
12
12
|
from math import inf
|
|
13
13
|
from typing import Tuple
|
kattis_cli/test_solution.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"""
|
|
3
3
|
|
|
4
4
|
from typing import Any, List, Dict
|
|
5
|
+
from math import inf
|
|
5
6
|
import glob
|
|
6
7
|
import time
|
|
7
8
|
import os
|
|
@@ -26,7 +27,7 @@ def test_samples(
|
|
|
26
27
|
problem_root_folder: str,
|
|
27
28
|
files: List[str],
|
|
28
29
|
lang_config: Dict[Any, Any],
|
|
29
|
-
accuracy: float =
|
|
30
|
+
accuracy: float = inf
|
|
30
31
|
) -> None:
|
|
31
32
|
"""Tests a problem by running all the .in files in
|
|
32
33
|
the problem folder and comparing the output to the .ans files.
|
|
@@ -118,28 +119,31 @@ def test_samples(
|
|
|
118
119
|
input_content = f.read()
|
|
119
120
|
input_content.replace(b'\r\n', b'\n') # Windows fix
|
|
120
121
|
out_file = in_file.replace('.in', '.ans')
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
try:
|
|
123
|
+
with open(out_file, 'rb') as f:
|
|
124
|
+
expected = f.read()
|
|
125
|
+
expected.replace(b'\r\n', b'\n')
|
|
126
|
+
except FileNotFoundError:
|
|
127
|
+
try:
|
|
128
|
+
out_file = in_file.replace('.in', '.out')
|
|
129
|
+
with open(out_file, 'rb') as f:
|
|
130
|
+
expected = f.read()
|
|
131
|
+
expected.replace(b'\r\n', b'\n')
|
|
132
|
+
except FileNotFoundError:
|
|
133
|
+
expected = b"No .ans or .out file found!"
|
|
124
134
|
# Run the program
|
|
125
135
|
code, ans, error = run_program.run(lang_config, mainclass, in_file)
|
|
126
|
-
expected = expected.strip()
|
|
127
136
|
if code != 0:
|
|
128
137
|
ans = error
|
|
129
138
|
# console.print(f"{ans=} {error=}")
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
else:
|
|
137
|
-
|
|
138
|
-
ans, accuracy):
|
|
139
|
-
result = "[bold green]✅[/bold green]"
|
|
140
|
-
count += 1
|
|
141
|
-
else:
|
|
142
|
-
result = "[bold red]❌[/bold red]"
|
|
139
|
+
|
|
140
|
+
# floating point comparison
|
|
141
|
+
if utility.check_answer(expected.decode('utf-8'),
|
|
142
|
+
ans, accuracy):
|
|
143
|
+
result = "[bold green]✅[/bold green]"
|
|
144
|
+
count += 1
|
|
145
|
+
else:
|
|
146
|
+
result = "[bold red]❌[/bold red]"
|
|
143
147
|
|
|
144
148
|
# UI Table Row ---
|
|
145
149
|
in_filename = Path(in_file).parts[-1]
|
kattis_cli/utils/utility.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
import os
|
|
5
|
+
from math import inf
|
|
5
6
|
from typing import Union
|
|
6
7
|
import yaml
|
|
7
8
|
|
|
@@ -60,21 +61,28 @@ def find_problem_root_folder(
|
|
|
60
61
|
raise FileNotFoundError("Error: Problem root folder not found.")
|
|
61
62
|
|
|
62
63
|
|
|
63
|
-
def
|
|
64
|
-
"""Compare two
|
|
64
|
+
def check_answer(expected: str, ans: str, places: float = inf) -> bool:
|
|
65
|
+
"""Compare two numeric strings with given precision.
|
|
65
66
|
|
|
66
67
|
Args:
|
|
67
68
|
expected (str): expected result
|
|
68
69
|
ans (str): actual result
|
|
69
|
-
places (float): decimal places for approximation
|
|
70
|
+
places (float): decimal places for approximation;
|
|
71
|
+
default inf for string comparison
|
|
70
72
|
|
|
71
73
|
Returns:
|
|
72
|
-
bool: True if the two
|
|
74
|
+
bool: True if the two values are equal, False otherwise
|
|
73
75
|
"""
|
|
74
76
|
expect_ans = expected.strip().split('\n')
|
|
75
77
|
actual_ans = ans.strip().split('\n')
|
|
76
78
|
if len(expect_ans) != len(actual_ans):
|
|
77
79
|
return False
|
|
80
|
+
|
|
81
|
+
if places == inf:
|
|
82
|
+
if expect_ans == actual_ans:
|
|
83
|
+
return True
|
|
84
|
+
else:
|
|
85
|
+
return False
|
|
78
86
|
try:
|
|
79
87
|
for i, ex_ans in enumerate(expect_ans):
|
|
80
88
|
flt_expected = float(ex_ans)
|
|
@@ -3,17 +3,17 @@ kattis_cli/__init__.py,sha256=afN92pog2fGyicY6KNBofYbCBYbYj4Fpi_INUSpsc-E,402
|
|
|
3
3
|
kattis_cli/download.py,sha256=kvUJdqRW3_ETvTd4XMruEs87RWPVHp_3a4VUhcYZEz8,5863
|
|
4
4
|
kattis_cli/kattis.py,sha256=uZct7vjbEW2HA5FJr1ItSZ-b07P9JQHv5SccV4Pqjo8,13771
|
|
5
5
|
kattis_cli/kattis_setup.py,sha256=rq_-Fz8oafxFJ8MOcxJqHQT8-bezgVHZXY2hm4EQF3U,4357
|
|
6
|
-
kattis_cli/main.py,sha256=
|
|
6
|
+
kattis_cli/main.py,sha256=paMidWBPOCInt_o9WsyS9HoYdNIU346u-KTn9YB2Ymk,4475
|
|
7
7
|
kattis_cli/settings.py,sha256=d5q4dYj9VqDSqPalleh2oZWtND-1bPB0T2IwdajFrBg,591
|
|
8
|
-
kattis_cli/test_solution.py,sha256=
|
|
8
|
+
kattis_cli/test_solution.py,sha256=6lXaj9V5Vhfw95OywVls3Ekv86OvSYDrWI-s29YBdpk,6190
|
|
9
9
|
kattis_cli/ui.py,sha256=dI06yncjm8sdLQkupPxGRODvQ6Gbawwuqn-67FrWg6I,2682
|
|
10
10
|
kattis_cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
kattis_cli/utils/config.py,sha256=6SIuiXA9sFADo8RZUj8A6rXb3uqmrWrmmArfZrqNQdw,2293
|
|
12
12
|
kattis_cli/utils/languages.py,sha256=wlhl1Zng0gQAtsWW6FLxdkdzqeeY_qQ94wqa3NLypEU,8758
|
|
13
13
|
kattis_cli/utils/run_program.py,sha256=NWQ6vtTeWgkaW75r91FIHGXR5cAbeu8yMb5hwzpYFsg,2613
|
|
14
|
-
kattis_cli/utils/utility.py,sha256=
|
|
15
|
-
kattis_cli-1.0.
|
|
16
|
-
kattis_cli-1.0.
|
|
17
|
-
kattis_cli-1.0.
|
|
18
|
-
kattis_cli-1.0.
|
|
19
|
-
kattis_cli-1.0.
|
|
14
|
+
kattis_cli/utils/utility.py,sha256=iPmfsHi-DwYxP9mKU_VurNnLJXf0dngwYPxUdqckgYo,2907
|
|
15
|
+
kattis_cli-1.0.5.dist-info/LICENSE,sha256=JmBa4SEKBCDWEgiOZcISU4tUCpli6xSpVlSYgkBXSNQ,1067
|
|
16
|
+
kattis_cli-1.0.5.dist-info/METADATA,sha256=0WYu19PZ0_ih3Y49Uxgj1JnZRi23fYgoDFYGCUSWN6Q,6603
|
|
17
|
+
kattis_cli-1.0.5.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
18
|
+
kattis_cli-1.0.5.dist-info/entry_points.txt,sha256=kyzGN20VqUPR_H0J_jJUKT-10-cAMFLVegQ6C7tbHss,47
|
|
19
|
+
kattis_cli-1.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|