Skip to content

Commit 6f05c53

Browse files
committed
Use spec reprs for case expr
1 parent da5835d commit 6f05c53

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

array_api_tests/test_special_cases.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,20 @@ def parse_cond(cond_str: str) -> Tuple[UnaryCheck, str]:
166166
if m := r_code.match(cond_str):
167167
value = parse_value(m.group(1))
168168
cond = make_eq(value)
169-
expr_template = "{} == " + str(value)
169+
expr_template = "{} == " + m.group(1)
170170
elif m := r_gt.match(cond_str):
171171
value = parse_value(m.group(1))
172172
cond = make_gt(value)
173-
expr_template = "{} > " + str(value)
173+
expr_template = "{} > " + m.group(1)
174174
elif m := r_lt.match(cond_str):
175175
value = parse_value(m.group(1))
176176
cond = make_lt(value)
177-
expr_template = "{} < " + str(value)
177+
expr_template = "{} < " + m.group(1)
178178
elif m := r_either_code.match(cond_str):
179179
v1 = parse_value(m.group(1))
180180
v2 = parse_value(m.group(2))
181181
cond = make_or(make_eq(v1), make_eq(v2))
182-
expr_template = "{} == " + str(v1) + " or {} == " + str(v2)
182+
expr_template = "{} == " + m.group(1) + " or {} == " + m.group(2)
183183
elif cond_str in ["finite", "a finite number"]:
184184
cond = math.isfinite
185185
expr_template = "isfinite({})"
@@ -217,12 +217,12 @@ def parse_cond(cond_str: str) -> Tuple[UnaryCheck, str]:
217217
def parse_result(result_str: str) -> Tuple[UnaryCheck, str]:
218218
if m := r_code.match(result_str):
219219
value = parse_value(m.group(1))
220-
check_result = make_eq(value)
221-
expr = str(value)
220+
check_result = make_eq(value) # type: ignore
221+
expr = m.group(1)
222222
elif m := r_approx_value.match(result_str):
223223
value = parse_value(m.group(1))
224-
check_result = make_rough_eq(value)
225-
expr = f"~{value}"
224+
check_result = make_rough_eq(value) # type: ignore
225+
expr = f"roughly {m.group(1)}"
226226
elif "positive" in result_str:
227227

228228
def check_result(result: float) -> bool:

0 commit comments

Comments
 (0)