Fix numpy dtype
@@ -53,7 +53,13 @@ class TestNorm(unittest.TestCase):
@testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4)
def test_norm(self, xp, dtype):
a = testing.shaped_arange(self.shape, xp, dtype)
- return xp.linalg.norm(a, self.ord, self.axis, self.keepdims)
+ res = xp.linalg.norm(a, self.ord, self.axis, self.keepdims)
+ if xp == numpy and not isinstance(res, numpy.ndarray):
+ real_dtype = a.real.dtype
+ if issubclass(real_dtype.type, numpy.inexact):
+ # Avoid numpy bug. See numpy/numpy#10667
+ res = res.astype(a.real.dtype)
+ return res
@testing.parameterize(*testing.product({
