def test_absolute(): arr = rand_int(2, 3) a = mnp.asarray(arr, dtype='float16') b = mnp.asarray(arr, dtype='float32') c = mnp.asarray(arr, dtype='uint8') d = mnp.asarray(arr, dtype='bool') match_array(mnp_absolute(a).asnumpy(), onp_absolute(a.asnumpy())) match_array(mnp_absolute(b).asnumpy(), onp_absolute(b.asnumpy())) match_array(mnp_absolute(c).asnumpy(), onp_absolute(c.asnumpy())) match_array(mnp_absolute(d).asnumpy(), onp_absolute(d.asnumpy())) where = rand_int(2, 3).astype('bool') out = rand_int(2, 3) match_array(mnp.absolute(a, out=mnp.asarray(out), where=mnp.asarray(where)).asnumpy(), onp.absolute(a.asnumpy(), out=out, where=where))
def mnp_absolute(x): return mnp.absolute(x)