def test_me_case_1(): a = ny.array([[10, 7, 4], [3, 2, 1]]) na = ny.array(a) ans = ny.std(na, axis=0) out = ny.zeros_like(ans) dst = ny.std(na, axis=0, out=out) assert_array_almost_equal(dst.get(), out.get())
def test_me_case_5(): ny_a = ny.array([[10, ny.nan, 4], [3, 2, 1]]) np_a = np.array([[10, np.nan, 4], [3, 2, 1]]) ans_ny = ny.std(ny_a, axis=1) ans_np = np.std(np_a, axis=1) print("ans1={} ans2={}".format(ans_ny, ans_np))
def ca5(arg): d = arg[0] t = arg[1] a = arg[2] k = arg[4] 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 na = np.array(seed) ans = np.std(na, axis=a, keepdims=k) np.save(fil, ans) ok = np.load(fil) dst = ny.std(na, axis=a, keepdims=k) return ok, dst
def test_me_case_4(): ny_a = ny.array([[10, ny.nan, 4], [3, 2, 1]]) np_a = np.array([[10, np.nan, 4], [3, 2, 1]]) ans_ny = ny.std(ny_a) ans_np = np.std(np_a) print("ans1={} ans2={}".format(ans_ny, ans_np)) assert_array_equal(ans_np, ans_ny.get())
def test_me_case_3(): ny_a = ny.array([[10, 7, 4], [3, 2, 1]]) np_a = np.array([[10, 7, 4], [3, 2, 1]]) ny_ans = ny.std(ny_a, ddof=1) np_ans = np.std(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.std(na) np.save(fil, src) ok = np.load(fil) dst = ny.std(na) return ok, dst
def ca2(arg): d = arg[0] a = arg[2] na = np.array(d) src = np.std(na, axis=a) np.save(fil, src) ok = np.load(fil) dst = ny.std(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 na = ny.array(seed) ans = ny.std(na, axis=a) out = ny.zeros_like(ans) dst = ny.std(na, axis=a, out=out) return dst, out
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 na = np.array(seed) src = np.std(na, axis=a) np.save(fil, src) ok = np.load(fil) dst = ny.std(na, axis=a) return ok, dst