(
array_namespace, device_name, dtype_name, weights, axis, normalize, expected
)
| 238 | ], |
| 239 | ) |
| 240 | def test_average( |
| 241 | array_namespace, device_name, dtype_name, weights, axis, normalize, expected |
| 242 | ): |
| 243 | xp, device = _array_api_for_tests(array_namespace, device_name, dtype_name) |
| 244 | array_in = numpy.asarray([[1, 2, 3], [4, 5, 6]], dtype=dtype_name) |
| 245 | array_in = xp.asarray(array_in, device=device) |
| 246 | if weights is not None: |
| 247 | weights = numpy.asarray(weights, dtype=dtype_name) |
| 248 | weights = xp.asarray(weights, device=device) |
| 249 | |
| 250 | with config_context(array_api_dispatch=True): |
| 251 | result = _average(array_in, axis=axis, weights=weights, normalize=normalize) |
| 252 | |
| 253 | if np_version < parse_version("2.0.0") or np_version >= parse_version("2.1.0"): |
| 254 | # NumPy 2.0 has a problem with the device attribute of scalar arrays: |
| 255 | # https://github.com/numpy/numpy/issues/26850 |
| 256 | assert array_api_device(array_in) == array_api_device(result) |
| 257 | |
| 258 | result = move_to(result, xp=numpy, device="cpu") |
| 259 | assert_allclose(result, expected, atol=_atol_for_type(dtype_name)) |
| 260 | |
| 261 | |
| 262 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected
searching dependent graphs…