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.median(na, axis=a, keepdims=k) np.save(fil, ans) ok = np.load(fil) dst = ny.median(na, axis=a, keepdims=k) return ok, dst
def test_me_case_3(): 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.median(ny_a, axis=1) ans_np = np.median(np_a, axis=1) print("ans1={} ans2={}".format(ans_ny, ans_np)) assert_array_equal(ans_np, ans_ny.get())
def ca1(arg): d = arg[0] na = np.array(d) src = np.median(na) np.save(fil, src) ok = np.load(fil) dst = ny.median(na) return dst, ok
def ca2(arg): d = arg[0] a = arg[2] na = np.array(d) src = np.median(na, axis=a) np.save(fil, src) ok = np.load(fil) dst = ny.median(na, axis=a) return dst, ok
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.median(na, axis=a) out = ny.zeros_like(ans) dst = ny.median(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.median(na, axis=a) np.save(fil, src) ok = np.load(fil) dst = ny.median(na, axis=a) return dst, ok
def test_me_case_2(): a = nlcpy.array([[10, 7, 4], [3, 2, 1]]) b = a.copy() ny.median(b, axis=None, overwrite_input=True) assert not ny.all(a == b)
def test_me_case_1(): a = ny.array([[10, 7, 4], [3, 2, 1]]) b = a.copy() ny.median(b, overwrite_input=False) print("a={} b={}".format(a, b)) assert ny.all(a == b)