(
T,
m,
percentage=1.0,
s=None,
mpdist_percentage=0.05,
mpdist_k=None,
mpdist_T_subseq_isconstant=None,
)
| 1531 | |
| 1532 | |
| 1533 | def get_all_mpdist_profiles( |
| 1534 | T, |
| 1535 | m, |
| 1536 | percentage=1.0, |
| 1537 | s=None, |
| 1538 | mpdist_percentage=0.05, |
| 1539 | mpdist_k=None, |
| 1540 | mpdist_T_subseq_isconstant=None, |
| 1541 | ): |
| 1542 | if s is not None: |
| 1543 | s = min(int(s), m) |
| 1544 | else: |
| 1545 | percentage = min(percentage, 1.0) |
| 1546 | percentage = max(percentage, 0.0) |
| 1547 | s = min(math.ceil(percentage * m), m) |
| 1548 | |
| 1549 | T_subseq_isconstant = rolling_isconstant(T, s, mpdist_T_subseq_isconstant) |
| 1550 | right_pad = 0 |
| 1551 | n_contiguous_windows = int(T.shape[0] // m) |
| 1552 | if T.shape[0] % m != 0: |
| 1553 | right_pad = int(m * np.ceil(T.shape[0] / m) - T.shape[0]) |
| 1554 | pad_width = (0, right_pad) |
| 1555 | T = np.pad(T, pad_width, mode="constant", constant_values=np.nan) |
| 1556 | T_subseq_isconstant = np.pad( |
| 1557 | T_subseq_isconstant, pad_width, mode="constant", constant_values=False |
| 1558 | ) |
| 1559 | |
| 1560 | n_padded = T.shape[0] |
| 1561 | D = np.empty((n_contiguous_windows, n_padded - m + 1)) |
| 1562 | |
| 1563 | # Iterate over non-overlapping subsequences, see Definition 3 |
| 1564 | for i in range(n_contiguous_windows): |
| 1565 | start = i * m |
| 1566 | stop = (i + 1) * m |
| 1567 | S_i = T[start:stop] |
| 1568 | S_i_subseq_isconstant = T_subseq_isconstant[start : stop - s + 1] |
| 1569 | D[i, :] = mpdist_vect( |
| 1570 | S_i, |
| 1571 | T, |
| 1572 | s, |
| 1573 | percentage=mpdist_percentage, |
| 1574 | k=mpdist_k, |
| 1575 | T_A_subseq_isconstant=S_i_subseq_isconstant, |
| 1576 | T_B_subseq_isconstant=T_subseq_isconstant, |
| 1577 | ) |
| 1578 | |
| 1579 | stop_idx = n_padded - m + 1 - right_pad |
| 1580 | D = D[:, :stop_idx] |
| 1581 | |
| 1582 | return D |
| 1583 | |
| 1584 | |
| 1585 | def mpdist_snippets( |
no test coverage detected