test_clip: make sure `min` and `max` have the same dtype as `x`
closes gh-359, closes gh-339
Per the spec: 'should have the same dtype as x': https://data-apis.org/array-api/latest/API_specification/generated/array_api.clip.html
The spec is not very clear on whether min and max can be int scalars for a real-valued x array, should probably clarify in the spec:
- On one hand, Hence, if x and either min or max have different data type kinds (e.g., integer versus floating-point), behavior is unspecified and thus implementation-dependent.
- On the other hand, https://data-apis.org/array-api/latest/API_specification/type_promotion.html#type-promotion, allows int->float->float32
Run tests with array_api_compat.{numpy,torch} and jax.numpy with 50_000 examples locally.
Tested the branch (running with 2_000 examples) locally and can verify that it resolves gh-359 for dpctl.tensor
The spec is not very clear on whether
minandmaxcan beintscalars for a real-valuedxarray, should probably clarify in the spec:
- On one hand, Hence, if x and either min or max have different data type kinds (e.g., integer versus floating-point), behavior is unspecified and thus implementation-dependent.
- On the other hand, https://data-apis.org/array-api/latest/API_specification/type_promotion.html#type-promotion, allows int->float->float32
Definitely the spec should clarify that int scalars should be cast to float.
https://github.com/data-apis/array-api/issues/925
Okay, let's merge this as approved for this seems to fix rather annoying failures. I've added a bullet point in https://github.com/data-apis/array-api-tests/issues/301 to track the "int min, float array" case. Thanks @ndgrigorian @crusaderky for the reviews.