MCPcopy
hub / github.com/stumpy-dev/stumpy / mpdist_vect

Function mpdist_vect

tests/naive.py:1399–1441  ·  view source on GitHub ↗
(
    T_A,
    T_B,
    m,
    percentage=0.05,
    k=None,
    T_A_subseq_isconstant=None,
    T_B_subseq_isconstant=None,
)

Source from the content-addressed store, hash-verified

1397
1398
1399def mpdist_vect(
1400 T_A,
1401 T_B,
1402 m,
1403 percentage=0.05,
1404 k=None,
1405 T_A_subseq_isconstant=None,
1406 T_B_subseq_isconstant=None,
1407):
1408 n_A = T_A.shape[0]
1409 n_B = T_B.shape[0]
1410 j = n_A - m + 1 # `k` is reserved for `P_ABBA` selection
1411 P_ABBA = np.empty(2 * j, dtype=np.float64)
1412 MPdist_vect = np.empty(n_B - n_A + 1)
1413
1414 if k is None:
1415 percentage = min(percentage, 1.0)
1416 percentage = max(percentage, 0.0)
1417 k = min(math.ceil(percentage * (2 * n_A)), 2 * j - 1)
1418
1419 k = min(int(k), P_ABBA.shape[0] - 1)
1420
1421 T_A_subseq_isconstant = rolling_isconstant(T_A, m, T_A_subseq_isconstant)
1422 T_B_subseq_isconstant = rolling_isconstant(T_B, m, T_B_subseq_isconstant)
1423 for i in range(n_B - n_A + 1):
1424 P_ABBA[:j] = stump(
1425 T_A,
1426 m,
1427 T_B[i : i + n_A],
1428 T_A_subseq_isconstant=T_A_subseq_isconstant,
1429 T_B_subseq_isconstant=T_B_subseq_isconstant[i : i + n_A - m + 1],
1430 )[:, 0]
1431 P_ABBA[j:] = stump(
1432 T_B[i : i + n_A],
1433 m,
1434 T_A,
1435 T_A_subseq_isconstant=T_B_subseq_isconstant[i : i + n_A - m + 1],
1436 T_B_subseq_isconstant=T_A_subseq_isconstant,
1437 )[:, 0]
1438 P_ABBA.sort()
1439 MPdist_vect[i] = P_ABBA[min(k, P_ABBA.shape[0] - 1)]
1440
1441 return MPdist_vect
1442
1443
1444def aampdist_vect(T_A, T_B, m, percentage=0.05, k=None, p=2.0):

Callers 1

get_all_mpdist_profilesFunction · 0.85

Calls 2

rolling_isconstantFunction · 0.70
stumpFunction · 0.70

Tested by

no test coverage detected