Open
Description
Running the following script
import numpy as np
import stumpy
import time
def test_extract_several_consensus():
Ts = [np.random.rand(n) for n in [64, 128]]
Ts_ref = [T.copy() for T in Ts]
Ts_comp = [T.copy() for T in Ts]
m = 20
k = 2 # Get the first `k` consensus motifs
for _ in range(k):
print(f'===== {_} =====')
radius, Ts_idx, subseq_idx = stumpy.ostinato(Ts_comp, m)
consensus_motif = Ts_comp[Ts_idx][subseq_idx : subseq_idx + m].copy()
for i in range(len(Ts_comp)):
if i == Ts_idx:
query_idx = subseq_idx
else:
query_idx = None
idx = np.argmin(stumpy.core.mass(consensus_motif, Ts_comp[i], query_idx=query_idx))
Ts_comp[i][idx : idx + m] = np.nan
Ts_ref[i][idx : idx + m] = np.nan
np.testing.assert_almost_equal(
Ts_ref[i][np.isfinite(Ts_ref[i])], Ts_comp[i][np.isfinite(Ts_comp[i])]
)
if __name__ == "__main__":
test_extract_several_consensus()
Gives:
===== 0 =====
===== 1 =====
/Users/nimasarajpoor/miniconda3/envs/py310/lib/python3.10/site-packages/stumpy/core.py:2257:
RuntimeWarning: divide by zero encountered in divide
I took a look at the code:
and tried to swap lines 2252 and 2253, but that did not work.
Also:
If I disable JIT, I get an extra warning, saying:
python3.10/site-packages/numpy/lib/nanfunctions.py:1879: RuntimeWarning: Degrees of freedom <= 0 for slice.
Metadata
Metadata
Assignees
Labels
No labels