Open
Description
I would like to compute float
and uint
, using array-api. However, I am not sure what is the best way to implement it. Following the type promotion rules
def f(x: xp.array) -> xp.array:
return x * xp.array(1j, dtype=xp.complex64 if x.dtype == xp.float32 else xp.complex128)
def g(x: xp.array) -> xp.array:
return x - xp.array(1, dtype=xp.int16 if x.dtype == xp.uint8 else xp.int32 if x.dtype == xp.uint16 else xp.int64)
This seems too redundant. What is the proper way to do this?