Description
clip states:
- min [...] Should have the same data type as x. Default: None.
- max [...] Should have the same data type as x. Default: None.
- For scalar min and/or max, the scalar values should follow type promotion rules for operations involving arrays and scalar operands (see Type Promotion Rules). 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.
The third point could use rewording in my opinion.
I believe that the intended meaning was that clip(Array[int64], 1.0)
has unspecified behaviour, as per type promotion rules.
However, the wording as it is could be interpreted that clip(Array[float64], 1)
also has unspecified behaviour, which doesn't make sense to me.
Proposal
Change
Hence, if
x
and eithermin
ormax
have different data type kinds (e.g., integer versus floating-point), behavior is unspecified and thus implementation-dependent.
To
Hence, if the scalar type of either
min
ormax
is incompatible with the data type ofx
(x
has integer data type and eithermin
ormax
are scalar floats), behavior is unspecified and thus implementation-dependent.
Backporting
As I believe this is only a clarification, it should be backported to previous versions. Note that, unlike most binops, this function has always accepted scalars for min/max and wording was the same in 2023.12.