def test_me_case_1(): a = ny.array([[10, 7, 4], [3, float('NaN'), 1]]) na = ny.array(a) ans = ny.nanvar(na, axis=0) out = ny.zeros_like(ans) dst = ny.nanvar(na, axis=0, out=out) assert_array_almost_equal(dst.get(), out.get())
def ca3(arg): d = arg[0] t = arg[1] a = arg[2] ss = 1 for x in d: ss *= x if t == 'int32' or t == 'int64' or t == 'uint32' or t == 'uint64': seed = [random.randint(1, ss * ss) for i in range(ss)] elif t == 'float64' or t == 'float32': seed = [random.random() for i in range(ss)] else: pass seed[0] = float('NaN') na = np.array(seed) src = np.nanvar(na, axis=a) np.save(fil, src) ok = np.load(fil) na = ny.array(seed) dst = ny.nanvar(na, axis=a) return ok, dst
def test_me_case_3(): ny_a = ny.array([[10, 7, 4], [3, float('NaN'), 1]]) np_a = np.array([[10, 7, 4], [3, float('NaN'), 1]]) ny_ans = ny.nanvar(ny_a, ddof=1) np_ans = np.nanvar(np_a, ddof=1) assert_array_almost_equal(ny_ans.get(), np_ans)
def ca1(arg): d = arg[0] na = np.array(d) src = np.nanvar(na) np.save(fil, src) ok = np.load(fil) dst = ny.nanvar(na) return ok, dst
def ca2(arg): d = arg[0] a = arg[2] na = np.array(d) src = np.nanvar(na, axis=a) np.save(fil, src) ok = np.load(fil) dst = ny.nanvar(na, axis=a) return ok, dst
def ca4(arg): d = arg[0] t = arg[1] a = arg[2] ss = 1 for x in d: ss *= x if t == 'int32' or t == 'int64' or t == 'uint32' or t == 'uint64': seed = [random.randint(1, ss * ss) for i in range(ss)] elif t == 'float64' or t == 'float32': seed = [random.random() for i in range(ss)] else: pass seed[0] = float('NaN') na = ny.array(seed) ans = ny.nanvar(na, axis=a) out = ny.zeros_like(ans) dst = ny.nanvar(na, axis=a, out=out) return dst, out