(
T_A,
m,
T_B,
percentage,
exclusion_zone,
pre_scrump,
s,
k=1,
T_A_subseq_isconstant=None,
T_B_subseq_isconstant=None,
)
| 1884 | |
| 1885 | |
| 1886 | def scrump( |
| 1887 | T_A, |
| 1888 | m, |
| 1889 | T_B, |
| 1890 | percentage, |
| 1891 | exclusion_zone, |
| 1892 | pre_scrump, |
| 1893 | s, |
| 1894 | k=1, |
| 1895 | T_A_subseq_isconstant=None, |
| 1896 | T_B_subseq_isconstant=None, |
| 1897 | ): |
| 1898 | n_A = T_A.shape[0] |
| 1899 | n_B = T_B.shape[0] |
| 1900 | l = n_A - m + 1 |
| 1901 | |
| 1902 | T_A_subseq_isconstant = rolling_isconstant(T_A, m, T_A_subseq_isconstant) |
| 1903 | T_B_subseq_isconstant = rolling_isconstant(T_B, m, T_B_subseq_isconstant) |
| 1904 | dist_matrix = distance_matrix(T_A, T_B, m) |
| 1905 | dist_matrix[np.isnan(dist_matrix)] = np.inf |
| 1906 | for i in range(n_A - m + 1): |
| 1907 | for j in range(n_B - m + 1): |
| 1908 | if np.isfinite(dist_matrix[i, j]): |
| 1909 | if T_A_subseq_isconstant[i] and T_B_subseq_isconstant[j]: |
| 1910 | dist_matrix[i, j] = 0 |
| 1911 | elif T_A_subseq_isconstant[i] or T_B_subseq_isconstant[j]: |
| 1912 | dist_matrix[i, j] = np.sqrt(m) |
| 1913 | else: # pragma: no cover |
| 1914 | pass |
| 1915 | |
| 1916 | if exclusion_zone is not None: |
| 1917 | diags = np.random.permutation(range(exclusion_zone + 1, n_A - m + 1)).astype( |
| 1918 | np.int64 |
| 1919 | ) |
| 1920 | else: |
| 1921 | diags = np.random.permutation(range(-(n_A - m + 1) + 1, n_B - m + 1)).astype( |
| 1922 | np.int64 |
| 1923 | ) |
| 1924 | |
| 1925 | n_chunks = int(np.ceil(1.0 / percentage)) |
| 1926 | ndist_counts = core._count_diagonal_ndist(diags, m, n_A, n_B) |
| 1927 | diags_ranges = core._get_array_ranges(ndist_counts, n_chunks, False) |
| 1928 | diags_ranges_start = diags_ranges[0, 0] |
| 1929 | diags_ranges_stop = diags_ranges[0, 1] |
| 1930 | |
| 1931 | P = np.full((l, k), np.inf, dtype=np.float64) # Topk |
| 1932 | PL = np.full(l, np.inf, dtype=np.float64) |
| 1933 | PR = np.full(l, np.inf, dtype=np.float64) |
| 1934 | |
| 1935 | I = np.full((l, k), -1, dtype=np.int64) |
| 1936 | IL = np.full(l, -1, dtype=np.int64) |
| 1937 | IR = np.full(l, -1, dtype=np.int64) |
| 1938 | |
| 1939 | for diag_idx in range(diags_ranges_start, diags_ranges_stop): |
| 1940 | g = diags[diag_idx] |
| 1941 | |
| 1942 | for i in range(n_A - m + 1): |
| 1943 | for j in range(n_B - m + 1): |
nothing calls this directly
no test coverage detected