def test_swap_random(data, seed):
a, b = data
np.random.seed(seed)
a_orig, b_orig = original.swap_random(a, b)
dcst_private._seed_numba(seed)
a_out, b_out = dcst.swap_random(a, b)
assert len(a_out) == len(b_out) == len(a) == len(b)
# Each entry should be present same number of times
ab = np.sort(np.concatenate((a, b)))
ab_out = np.sort(np.concatenate((a_out, b_out)))
assert np.allclose(ab, ab_out, atol=atol, equal_nan=True)
# Check for swaps matching
for i in range(len(a)):
ab = np.array([a[i], b[i]])
ab_out = np.array([a_out[i], b_out[i]])
assert ab[0] in ab_out
assert ab[1] in ab_out
评论列表
文章目录