def test_aampdist_vect(T_A, T_B): m = 3 for p in [1.0, 2.0, 3.0]: ref_aampdist_vect = naive.aampdist_vect(T_A, T_B, m, p=p) comp_aampdist_vect = _aampdist_vect(T_A, T_B, m, p=p) npt.assert_almost_equal(ref_aampdist_vect, comp_aampdist_vect)
def test_aampdist_vect_k(T_A, T_B, k): m = 3 n_A = T_A.shape[0] n_B = T_B.shape[0] j = n_A - m + 1 # `k` is reserved for `P_ABBA` selection P_ABBA = np.empty(2 * j, dtype=np.float64) ref_mpdist_vect = np.empty(n_B - n_A + 1) k = min(int(k), P_ABBA.shape[0] - 1) for i in range(n_B - n_A + 1): P_ABBA[:j] = naive.aamp(T_A, m, T_B[i : i + n_A])[:, 0] P_ABBA[j:] = naive.aamp(T_B[i : i + n_A], m, T_A)[:, 0] P_ABBA.sort() ref_mpdist_vect[i] = P_ABBA[min(k, P_ABBA.shape[0] - 1)] comp_mpdist_vect = _aampdist_vect(T_A, T_B, m, k=k) npt.assert_almost_equal(ref_mpdist_vect, comp_mpdist_vect)
def test_aampdist_vect(T_A, T_B): m = 3 n_A = T_A.shape[0] n_B = T_B.shape[0] j = n_A - m + 1 # `k` is reserved for `P_ABBA` selection P_ABBA = np.empty(2 * j, dtype=np.float64) ref_mpdist_vect = np.empty(n_B - n_A + 1) percentage = 0.05 k = min(math.ceil(percentage * (2 * n_A)), 2 * j - 1) k = min(int(k), P_ABBA.shape[0] - 1) for i in range(n_B - n_A + 1): P_ABBA[:j] = naive.aamp(T_A, m, T_B[i : i + n_A])[:, 0] P_ABBA[j:] = naive.aamp(T_B[i : i + n_A], m, T_A)[:, 0] P_ABBA.sort() ref_mpdist_vect[i] = P_ABBA[k] comp_mpdist_vect = _aampdist_vect(T_A, T_B, m) npt.assert_almost_equal(ref_mpdist_vect, comp_mpdist_vect)
def test_aampdist_vect_k(T_A, T_B, k): m = 3 ref_aampdist_vect = naive.aampdist_vect(T_A, T_B, m, k=k) comp_aampdist_vect = _aampdist_vect(T_A, T_B, m, k=k) npt.assert_almost_equal(ref_aampdist_vect, comp_aampdist_vect)
def test_aampdist_vect_percentage(T_A, T_B, percentage): m = 3 ref_aampdist_vect = naive.aampdist_vect(T_A, T_B, m, percentage=percentage) comp_aampdist_vect = _aampdist_vect(T_A, T_B, m, percentage=percentage) npt.assert_almost_equal(ref_aampdist_vect, comp_aampdist_vect)