add support for dtype kinds in `astype`
https://github.com/data-apis/array-api/pull/848#issuecomment-2638722698
This seems to have slipped under the radar. Could you remind me what are the motivating use cases? IIUC, one was float32->complex64, which is now IMO adequately handled by 1j*float32_array -> complex64_array. Was there something about signed/unsigned integers? My search-foo is failing me
Hmm, not sure if there was a real-world motivating case for signed/unsigned integers, but in general I still think this is rather nice to have. Suppose you are using something like this in a context of parametrising over dtype kinds, something like
dtype_id = 1.0 if dtype_kind=="float" else 1j # or more cases
x *= dtype_id
can become
x = xp.astype(x, kind=dtype_kind)
which is not only cleaner but also semantically much nicer IMO!
This is the int/uint discussion I was trying to remember: https://github.com/data-apis/array-api/issues/859#issuecomment-2502160704