@problem
-- Problem
¶
Problem
And problem
API¶
The module defines the Problem class, which is the abstract representation of a assignment problem.
Problem ¶
Bases: ModuleLoader
, Generic[ProbInputType, ProbOutputType]
An abstract representation of a assignment problem.
Source code in src/gapper/core/problem/problem_def.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
expected_submission_name property
¶
The expected name of the submission.
__call__ ¶
__init__ ¶
Create a problem object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution | Callable[ProbInputType, ProbOutputType] | The solution to the problem. | required |
config | ProblemConfig | The configuration of the problem. | required |
Source code in src/gapper/core/problem/problem_def.py
add_hook ¶
add_test_parameter ¶
Add a test parameter to the problem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_param | TestParam | The test parameter to add. | required |
Source code in src/gapper/core/problem/problem_def.py
from_path classmethod
¶
Load a problem from a path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | Path | The path to load the problem from. If the path is a directory, it will be searched recursively. But only one problem can be defined in a directory. | required |
Source code in src/gapper/core/problem/problem_def.py
generate_tests ¶
problem ¶
problem(*, is_script: bool = False, check_stdout: Optional[bool] = None, mock_input: Optional[bool] = None, context: Iterable[str] = (), easy_context: bool = True) -> Callable[[Callable[ProbInputType, ProbOutputType]], Problem[ProbInputType, ProbOutputType]]
Create a problem object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_script | bool | Whether this problem is a script. This cannot coexist with check_stdout or mock_input. | False |
check_stdout | Optional[bool] | Whether to check the stdout of the solution. | None |
mock_input | Optional[bool] | Whether to mock the input of the solution. | None |
context | Iterable[str] | The context to capture from the submission. | () |
easy_context | bool | Whether to use context directly in gap override tests. | True |
Source code in src/gapper/core/problem/problem_def.py
Problem
Configs API¶
Problem configuration.
ProblemConfig dataclass
¶
Problem configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
check_stdout | bool | Whether to check the stdout of the solution. | False |
mock_input | bool | Whether to mock the input of the solution. | False |
captured_context | Iterable[str] | The context to capture from the submission. | () |
easy_context | bool | Whether to use context directly in gap override tests. | True |
is_script | bool | Whether this problem is a script. | False |
extras | ProblemConfigExtra | Extra problem configuration dictionary. | lambda: defaultdict(None)() |