|
32 | 32 | from . import hypothesis_helpers as hh
|
33 | 33 | from . import pytest_helpers as ph
|
34 | 34 | from . import shape_helpers as sh
|
35 |
| -from . import xps |
36 |
| -from . import xp |
| 35 | +from . import xp, xps |
37 | 36 | from .stubs import category_to_funcs
|
38 | 37 |
|
39 | 38 | pytestmark = pytest.mark.ci
|
@@ -126,6 +125,8 @@ def abs_cond(i: float) -> bool:
|
126 | 125 | "infinity": float("inf"),
|
127 | 126 | "0": 0.0,
|
128 | 127 | "1": 1.0,
|
| 128 | + "False": 0.0, |
| 129 | + "True": 1.0, |
129 | 130 | }
|
130 | 131 | r_value = re.compile(r"([+-]?)(.+)")
|
131 | 132 | r_pi = re.compile(r"(\d?)π(?:/(\d))?")
|
@@ -507,7 +508,10 @@ def __repr__(self) -> str:
|
507 | 508 | return f"{self.__class__.__name__}(<{self}>)"
|
508 | 509 |
|
509 | 510 |
|
510 |
| -r_case_block = re.compile(r"\*\*Special [Cc]ases\*\*\n+((?:(.*\n)+))\n+\s*Parameters") |
| 511 | +r_case_block = re.compile( |
| 512 | + r"\*\*Special [Cc]ases\*\*\n+((?:(.*\n)+))\n+\s*" |
| 513 | + r"(?:.+\n--+)?(?:\.\. versionchanged.*)?" |
| 514 | +) |
511 | 515 | r_case = re.compile(r"\s+-\s*(.*)\.")
|
512 | 516 |
|
513 | 517 |
|
@@ -1121,6 +1125,9 @@ def parse_binary_case_block(case_block: str) -> List[BinaryCase]:
|
1121 | 1125 | iop_params = []
|
1122 | 1126 | func_to_op: Dict[str, str] = {v: k for k, v in dh.op_to_func.items()}
|
1123 | 1127 | for stub in category_to_funcs["elementwise"]:
|
| 1128 | + # if stub.__name__ == "abs": |
| 1129 | + # import ipdb; ipdb.set_trace() |
| 1130 | + |
1124 | 1131 | if stub.__doc__ is None:
|
1125 | 1132 | warn(f"{stub.__name__}() stub has no docstring")
|
1126 | 1133 | continue
|
@@ -1167,6 +1174,8 @@ def parse_binary_case_block(case_block: str) -> List[BinaryCase]:
|
1167 | 1174 | op = getattr(operator, op_name)
|
1168 | 1175 | name_to_func[op_name] = op
|
1169 | 1176 | # We collect inplace operator test cases seperately
|
| 1177 | + if stub.__name__ == "equal": |
| 1178 | + break |
1170 | 1179 | iop_name = "__i" + op_name[2:]
|
1171 | 1180 | iop = getattr(operator, iop_name)
|
1172 | 1181 | for case in cases:
|
@@ -1259,7 +1268,12 @@ def test_binary(func_name, func, case, x1, x2, data):
|
1259 | 1268 |
|
1260 | 1269 | res = func(x1, x2)
|
1261 | 1270 | # sanity check
|
1262 |
| - ph.assert_result_shape(func_name, in_shapes=[x1.shape, x2.shape], out_shape=res.shape, expected=result_shape) |
| 1271 | + ph.assert_result_shape( |
| 1272 | + func_name, |
| 1273 | + in_shapes=[x1.shape, x2.shape], |
| 1274 | + out_shape=res.shape, |
| 1275 | + expected=result_shape, |
| 1276 | + ) |
1263 | 1277 |
|
1264 | 1278 | good_example = False
|
1265 | 1279 | for l_idx, r_idx, o_idx in all_indices:
|
@@ -1311,7 +1325,9 @@ def test_iop(iop_name, iop, case, oneway_dtypes, oneway_shapes, data):
|
1311 | 1325 | res = xp.asarray(x1, copy=True)
|
1312 | 1326 | res = iop(res, x2)
|
1313 | 1327 | # sanity check
|
1314 |
| - ph.assert_result_shape(iop_name, in_shapes=[x1.shape, x2.shape], out_shape=res.shape) |
| 1328 | + ph.assert_result_shape( |
| 1329 | + iop_name, in_shapes=[x1.shape, x2.shape], out_shape=res.shape |
| 1330 | + ) |
1315 | 1331 |
|
1316 | 1332 | good_example = False
|
1317 | 1333 | for l_idx, r_idx, o_idx in all_indices:
|
|
0 commit comments