Raises an AssertionError if two array_like objects are not ordered by less than. Given two array_like objects `x` and `y`, check that the shape is equal and all elements of `x` are strictly less than the corresponding elements of `y` (but see the Notes for the special handling
(x, y, err_msg='', verbose=True, *, strict=False)
| 1232 | |
| 1233 | |
| 1234 | def assert_array_less(x, y, err_msg='', verbose=True, *, strict=False): |
| 1235 | """ |
| 1236 | Raises an AssertionError if two array_like objects are not ordered by less |
| 1237 | than. |
| 1238 | |
| 1239 | Given two array_like objects `x` and `y`, check that the shape is equal and |
| 1240 | all elements of `x` are strictly less than the corresponding elements of |
| 1241 | `y` (but see the Notes for the special handling of a scalar). An exception |
| 1242 | is raised at shape mismatch or values that are not correctly ordered. In |
| 1243 | contrast to the standard usage in NumPy, no assertion is raised if both |
| 1244 | objects have NaNs in the same positions. |
| 1245 | |
| 1246 | Parameters |
| 1247 | ---------- |
| 1248 | x : array_like |
| 1249 | The smaller object to check. |
| 1250 | y : array_like |
| 1251 | The larger object to compare. |
| 1252 | err_msg : string |
| 1253 | The error message to be printed in case of failure. |
| 1254 | verbose : bool |
| 1255 | If True, the conflicting values are appended to the error message. |
| 1256 | strict : bool, optional |
| 1257 | If True, raise an AssertionError when either the shape or the data |
| 1258 | type of the array_like objects does not match. The special |
| 1259 | handling for scalars mentioned in the Notes section is disabled. |
| 1260 | |
| 1261 | .. versionadded:: 2.0.0 |
| 1262 | |
| 1263 | Raises |
| 1264 | ------ |
| 1265 | AssertionError |
| 1266 | If x is not strictly smaller than y, element-wise. |
| 1267 | |
| 1268 | See Also |
| 1269 | -------- |
| 1270 | assert_array_equal: tests objects for equality |
| 1271 | assert_array_almost_equal: test objects for equality up to precision |
| 1272 | |
| 1273 | Notes |
| 1274 | ----- |
| 1275 | When one of `x` and `y` is a scalar and the other is array_like, the |
| 1276 | function performs the comparison as though the scalar were broadcasted |
| 1277 | to the shape of the array. This behaviour can be disabled with the `strict` |
| 1278 | parameter. |
| 1279 | |
| 1280 | Examples |
| 1281 | -------- |
| 1282 | The following assertion passes because each finite element of `x` is |
| 1283 | strictly less than the corresponding element of `y`, and the NaNs are in |
| 1284 | corresponding locations. |
| 1285 | |
| 1286 | >>> x = [1.0, 1.0, np.nan] |
| 1287 | >>> y = [1.1, 2.0, np.nan] |
| 1288 | >>> np.testing.assert_array_less(x, y) |
| 1289 | |
| 1290 | The following assertion fails because the zeroth element of `x` is no |
| 1291 | longer strictly less than the zeroth element of `y`. |
searching dependent graphs…