Currently, the private xp test functions cannot compare a scaler with an array, even though we are ultimately using np.testing, we check for the equality of the total number of elements before:
|
actual_size = math.prod(actual_shape) # pyright: ignore[reportUnknownArgumentType] |
To align more with numpy testing behaviour, we can use the strict parameter to check for this. If set to true, do the above check, if False check if it can broadcast. See the numpy example here.
An even cleaner solution would be to remove the above check entirely and pass the strict parameter directly to the np.testing function call. The current numpy behaviour is different from what's suggested by these comments:
|
# Ignore shape, but check flattened size. This is normally done by |
Either it refers to an older version of numpy testing, or I'm missing something.
Currently, the private xp test functions cannot compare a scaler with an array, even though we are ultimately using
np.testing, we check for the equality of the total number of elements before:array-api-extra/src/array_api_extra/_lib/_testing.py
Line 84 in 5045afa
To align more with numpy testing behaviour, we can use the strict parameter to check for this. If set to true, do the above check, if False check if it can broadcast. See the numpy example here.
An even cleaner solution would be to remove the above check entirely and pass the
strictparameter directly to the np.testing function call. The current numpy behaviour is different from what's suggested by these comments:array-api-extra/src/array_api_extra/_lib/_testing.py
Line 81 in 5045afa
Either it refers to an older version of numpy testing, or I'm missing something.