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

Function mpdist

tests/naive.py:1467–1507  ·  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

1465
1466
1467def mpdist(
1468 T_A,
1469 T_B,
1470 m,
1471 percentage=0.05,
1472 k=None,
1473 T_A_subseq_isconstant=None,
1474 T_B_subseq_isconstant=None,
1475):
1476 percentage = min(percentage, 1.0)
1477 percentage = max(percentage, 0.0)
1478 n_A = T_A.shape[0]
1479 n_B = T_B.shape[0]
1480 P_ABBA = np.empty(n_A - m + 1 + n_B - m + 1, dtype=np.float64)
1481 if k is not None:
1482 k = int(k)
1483 else:
1484 k = min(math.ceil(percentage * (n_A + n_B)), n_A - m + 1 + n_B - m + 1 - 1)
1485
1486 P_ABBA[: n_A - m + 1] = stump(
1487 T_A,
1488 m,
1489 T_B,
1490 T_A_subseq_isconstant=T_A_subseq_isconstant,
1491 T_B_subseq_isconstant=T_B_subseq_isconstant,
1492 )[:, 0]
1493 P_ABBA[n_A - m + 1 :] = stump(
1494 T_B,
1495 m,
1496 T_A,
1497 T_A_subseq_isconstant=T_B_subseq_isconstant,
1498 T_B_subseq_isconstant=T_A_subseq_isconstant,
1499 )[:, 0]
1500
1501 P_ABBA.sort()
1502 MPdist = P_ABBA[k]
1503 if ~np.isfinite(MPdist): # pragma: no cover
1504 k = np.isfinite(P_ABBA[:k]).sum() - 1
1505 MPdist = P_ABBA[k]
1506
1507 return MPdist
1508
1509
1510def aampdist(T_A, T_B, m, percentage=0.05, k=None, p=2.0):

Callers

nothing calls this directly

Calls 1

stumpFunction · 0.70

Tested by

no test coverage detected