def test_complex_dtype_nansum(self, ndim, dtype, keepdims):
        """This test checks if nansum works as expected for complex
        datatypes. The parametrized datatype is that of real/complex
        component, so float32 would correspond to complex64 and
        float64 would correspond to complex128.
        """
        shape = (3,) * ndim
        size = prod(shape)

        r = np.random.random(shape).astype(dtype)
        c = np.random.random(shape).astype(dtype)

        # get index of nan
        index_nan = np.random.randint(low=0, high=size)
        index_nan = np.unravel_index(index_nan, shape)

        # set an element to nan
        r[index_nan] = np.nan
        c[index_nan] = np.nan

        in_np = r + 1j * c

        in_num = num.array(in_np)
        in_num[index_nan] = num.nan

        out_num = num.nansum(in_num, keepdims=keepdims)
        out_np = np.nansum(in_np, keepdims=keepdims)

        assert allclose(out_num, out_np, rtol=1e-4)
This test checks if nansum works as expected for complex
        datatypes. The parametrized datatype is that of real/complex
        component, so float32 would correspond to complex64 and
        float64 would correspond to complex128.
        
tests/integration/test_nan_reduction.py