wannesm / dtaidistance

Time series distances: Dynamic Time Warping (fast DTW implementation in C)
Other
1.08k stars 184 forks source link

Subsequence search kbest_matches with k = None broken since commit 31f7703 #184

Closed tommedema closed 1 year ago

tommedema commented 1 year ago

I was confused by a sudden lack of results in my subsequence search, and have been able to identify a specific commit that seems to have broken the following code by methodically reinstalling and going forward one commit at a time until the below test breaks:

pip uninstall dtaidistance
git clone https://github.com/wannesm/dtaidistance.git && cd dtaidistance
git checkout <next commit to test>
sed -i '' 's/double/float/g' dtaidistance/jinja/generate.py dtaidistance/lib/DTAIDistanceC/DTAIDistanceC/dd_globals.h
cd dtaidistance/jinja && make && cd ../..
pip install .
< restart Jupyter server and kernel completely >

Consider this standalone reproducible "test" case:

from dtaidistance.subsequence.dtw import subsequence_search
import numpy as np

series = np.array(
    [[0.032258063554763794, 0.12903225421905518, 0.09677419066429138, 0.19354838132858276, 0.22580644488334656], [0.14516128599643707, 0.4516128897666931, 0.5483871102333069, 0.4193548262119293, 0.032258063554763794], [0.22580644488334656, 0.11290322244167328, 0.06451612710952759, 0.11290322244167328, 0.3870967626571655], [0.09677419066429138, 0.19354838132858276, 0.16129031777381897, 0.12903225421905518, 0.22580644488334656], [0.16129031777381897, 0.06451612710952759, 0.032258063554763794, 0.09677419066429138, 0.12903225421905518], [0.7096773982048035, 0.7419354915618896, 0.5806451439857483, 0.5483871102333069, 0.774193525314331], [0.5806451439857483, 0.5483871102333069, 0.4516128897666931, 0.25806450843811035, 0.6451612710952759], [0.16129031777381897, 0.35483869910240173, 0.25806450843811035, 0.12903225421905518, 0.3870967626571655], [0.5806451439857483, 0.7580645084381104, 0.9354838728904724, 0.9032257795333862, 0.8709677457809448], [0.8709677457809448, 0.9677419066429138, 0.8064516186714172, 0.6129032373428345, 0.7419354915618896], [0.8064516186714172, 0.9354838728904724, 0.8709677457809448, 0.9032257795333862, 0.774193525314331], [0.8387096524238586, 0.774193525314331, 0.7419354915618896, 0.8709677457809448, 0.9354838728904724], [0.8387096524238586, 0.8709677457809448, 0.8064516186714172, 0.774193525314331, 0.9032257795333862], [0.9354838728904724, 0.9677419066429138, 0.8709677457809448, 0.9032257795333862, 0.8387096524238586], [0.8709677457809448, 1.0, 0.9354838728904724, 0.9677419066429138, 0.9032257795333862], [0.9677419066429138, 0.8709677457809448, 0.4838709533214569, 0.5645161271095276, 0.7096773982048035], [0.7096773982048035, 0.8064516186714172, 1.0, 0.9032257795333862, 0.9677419066429138], [0.4516128897666931, 0.6612903475761414, 0.6612903475761414, 0.8064516186714172, 0.9032257795333862], [0.3870967626571655, 0.4516128897666931, 0.6612903475761414, 0.6612903475761414, 0.8064516186714172], [0.12903225421905518, 0.09677419066429138, 0.3870967626571655, 0.4516128897666931, 0.6451612710952759], [0.8709677457809448, 0.7096773982048035, 0.6451612710952759, 0.25806450843811035, 0.5483871102333069], [0.14516128599643707, 0.5483871102333069, 0.8709677457809448, 0.7096773982048035, 0.6451612710952759], [0.25806450843811035, 0.12903225421905518, 0.22580644488334656, 0.16129031777381897, 0.5645161271095276], [0.8064516186714172, 0.5161290168762207, 0.7096773982048035, 0.7419354915618896, 0.774193525314331], [0.9677419066429138, 0.9032257795333862, 0.8064516186714172, 0.5806451439857483, 0.774193525314331], [0.9354838728904724, 1.0, 0.8387096524238586, 0.9677419066429138, 0.9032257795333862], [0.9032257795333862, 0.9354838728904724, 1.0, 0.8709677457809448, 0.9677419066429138], [0.8709677457809448, 0.8064516186714172, 0.9354838728904724, 0.9677419066429138, 1.0], [0.6774193644523621, 1.0, 0.8709677457809448, 0.8387096524238586, 0.9677419066429138], [0.32258063554763794, 0.29032257199287415, 0.4193548262119293, 0.6935483813285828, 1.0], [0.5483871102333069, 0.32258063554763794, 0.29032257199287415, 0.4193548262119293, 0.725806474685669], [0.6451612710952759, 0.5161290168762207, 0.774193525314331, 0.4838709533214569, 0.29032257199287415], [0.35483869910240173, 0.32258063554763794, 0.6129032373428345, 0.4516128897666931, 0.774193525314331], [0.12903225421905518, 0.22580644488334656, 0.19354838132858276, 0.35483869910240173, 0.32258063554763794], [0.06451612710952759, 0.12903225421905518, 0.22580644488334656, 0.19354838132858276, 0.32258063554763794], [0.09677419066429138, 0.032258063554763794, 0.06451612710952759, 0.12903225421905518, 0.19354838132858276], [0.16129031777381897, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759, 0.12903225421905518], [0.19354838132858276, 0.12903225421905518, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759], [0.4193548262119293, 0.29032257199287415, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759], [0.4516128897666931, 0.3870967626571655, 0.25806450843811035, 0.06451612710952759, 0.032258063554763794], [0.4516128897666931, 0.25806450843811035, 0.7419354915618896, 0.5806451439857483, 0.3870967626571655], [0.16129031777381897, 0.22580644488334656, 0.4516128897666931, 0.25806450843811035, 0.7419354915618896], [0.5161290168762207, 0.16129031777381897, 0.22580644488334656, 0.4516128897666931, 0.25806450843811035], [0.5483871102333069, 0.4838709533214569, 0.16129031777381897, 0.22580644488334656, 0.4193548262119293], [0.12903225421905518, 0.5161290168762207, 0.4516128897666931, 0.16129031777381897, 0.22580644488334656], [0.6129032373428345, 0.16129031777381897, 0.09677419066429138, 0.12903225421905518, 0.4193548262119293], [0.7419354915618896, 0.5806451439857483, 0.16129031777381897, 0.09677419066429138, 0.12903225421905518], [0.32258063554763794, 0.12903225421905518, 0.35483869910240173, 0.5806451439857483, 0.6129032373428345], [0.3870967626571655, 0.32258063554763794, 0.12903225421905518, 0.35483869910240173, 0.5806451439857483], [0.29032257199287415, 0.3870967626571655, 0.32258063554763794, 0.12903225421905518, 0.35483869910240173], [0.12903225421905518, 0.09677419066429138, 0.25806450843811035, 0.32258063554763794, 0.29032257199287415], [0.4193548262119293, 0.12903225421905518, 0.09677419066429138, 0.25806450843811035, 0.29032257199287415], [0.16129031777381897, 0.12903225421905518, 0.25806450843811035, 0.32258063554763794, 0.29032257199287415], [0.06451612710952759, 0.032258063554763794, 0.16129031777381897, 0.12903225421905518, 0.25806450843811035], [0.16129031777381897, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794, 0.12903225421905518], [0.8709677457809448, 0.8064516186714172, 0.9032257795333862, 0.9677419066429138, 1.0], [0.9032257795333862, 1.0, 0.9354838728904724, 0.8709677457809448, 0.9677419066429138], [0.5806451439857483, 0.6774193644523621, 0.6290322542190552, 0.9032257795333862, 1.0], [0.5806451439857483, 0.6129032373428345, 0.7096773982048035, 0.6612903475761414, 0.9354838728904724], [0.4838709533214569, 0.5806451439857483, 0.6451612710952759, 0.6774193644523621, 0.7419354915618896], [0.7419354915618896, 0.5161290168762207, 0.6129032373428345, 0.6774193644523621, 0.7096773982048035], [0.4516128897666931, 0.5161290168762207, 0.7419354915618896, 0.5806451439857483, 0.6774193644523621], [0.774193525314331, 0.4838709533214569, 0.5161290168762207, 0.5806451439857483, 0.7419354915618896], [0.8064516186714172, 0.774193525314331, 0.5161290168762207, 0.5483871102333069, 0.6129032373428345], [0.6451612710952759, 0.5806451439857483, 0.7419354915618896, 1.0, 0.9677419066429138], [0.9677419066429138, 0.6774193644523621, 0.6129032373428345, 0.774193525314331, 1.0], [1.0, 0.9677419066429138, 0.8709677457809448, 0.8064516186714172, 0.9354838728904724], [0.8387096524238586, 0.9032257795333862, 0.9354838728904724, 0.9677419066429138, 1.0], [0.8387096524238586, 0.8709677457809448, 0.9032257795333862, 0.9677419066429138, 1.0], [0.19354838132858276, 0.4516128897666931, 0.6451612710952759, 0.774193525314331, 0.7419354915618896], [0.06451612710952759, 0.16129031777381897, 0.19354838132858276, 0.4516128897666931, 0.6451612710952759], [0.20967741310596466, 0.06451612710952759, 0.032258063554763794, 0.09677419066429138, 0.14516128599643707], [0.09677419066429138, 0.16129031777381897, 0.22580644488334656, 0.06451612710952759, 0.032258063554763794], [0.19354838132858276, 0.16129031777381897, 0.29032257199287415, 0.09677419066429138, 0.032258063554763794], [0.06451612710952759, 0.032258063554763794, 0.22580644488334656, 0.30645161867141724, 0.4193548262119293], [0.5645161271095276, 0.12903225421905518, 0.06451612710952759, 0.032258063554763794, 0.22580644488334656], [1.0, 0.8387096524238586, 0.06451612710952759, 0.5, 0.09677419066429138], [0.22580644488334656, 0.3870967626571655, 0.4354838728904724, 1.0, 0.8387096524238586], [1.0, 0.9354838728904724, 0.6451612710952759, 0.5161290168762207, 0.35483869910240173], [0.9677419066429138, 0.8709677457809448, 0.774193525314331, 0.8225806355476379, 0.8225806355476379], [0.5806451439857483, 0.9354838728904724, 0.6774193644523621, 0.8387096524238586, 0.9677419066429138], [0.5161290168762207, 0.5806451439857483, 0.9677419066429138, 0.6774193644523621, 0.8387096524238586], [0.9354838728904724, 1.0, 0.6451612710952759, 0.5806451439857483, 0.7096773982048035], [0.25806450843811035, 0.22580644488334656, 0.29032257199287415, 0.32258063554763794, 0.7419354915618896], [0.12903225421905518, 0.22580644488334656, 0.29032257199287415, 0.25806450843811035, 0.35483869910240173], [0.9354838728904724, 0.9677419066429138, 0.9032257795333862, 0.5483871102333069, 0.6129032373428345], [0.8709677457809448, 1.0, 0.9677419066429138, 0.9032257795333862, 0.9354838728904724], [0.8548387289047241, 0.6451612710952759, 0.5806451439857483, 0.8064516186714172, 0.8548387289047241], [0.9677419066429138, 0.8709677457809448, 0.6774193644523621, 0.6129032373428345, 0.8387096524238586], [1.0, 0.9677419066429138, 0.8709677457809448, 0.7096773982048035, 0.6451612710952759], [0.9354838728904724, 0.8387096524238586, 1.0, 0.9677419066429138, 0.8709677457809448], [0.8064516186714172, 0.774193525314331, 0.9354838728904724, 0.8709677457809448, 0.9677419066429138], [0.4516128897666931, 0.5322580933570862, 0.5806451439857483, 0.7096773982048035, 0.774193525314331], [0.35483869910240173, 0.032258063554763794, 0.7419354915618896, 0.5806451439857483, 0.5483871102333069], [0.09677419066429138, 0.16129031777381897, 0.29032257199287415, 0.25806450843811035, 0.22580644488334656], [0.29032257199287415, 0.04838709533214569, 0.19354838132858276, 0.04838709533214569, 0.09677419066429138], [0.5483871102333069, 0.5161290168762207, 0.6774193644523621, 0.6451612710952759, 0.9032257795333862], [0.4838709533214569, 0.7096773982048035, 0.6774193644523621, 0.774193525314331, 0.6451612710952759], [1.0, 0.9032257795333862, 0.774193525314331, 0.8064516186714172, 0.725806474685669], [0.9032257795333862, 0.8709677457809448, 0.9354838728904724, 0.9677419066429138, 1.0], [0.7096773982048035, 0.6451612710952759, 0.8387096524238586, 0.9354838728904724, 0.9032257795333862], [0.25806450843811035, 0.4516128897666931, 0.6451612710952759, 0.4193548262119293, 0.5161290168762207], [0.22580644488334656, 0.12903225421905518, 0.06451612710952759, 0.25806450843811035, 0.4193548262119293], [0.19354838132858276, 0.22580644488334656, 0.12903225421905518, 0.06451612710952759, 0.25806450843811035], [0.19354838132858276, 0.09677419066429138, 0.29032257199287415, 0.12903225421905518, 0.16129031777381897], [0.19354838132858276, 0.06451612710952759, 0.12903225421905518, 0.09677419066429138, 0.22580644488334656], [0.06451612710952759, 0.09677419066429138, 0.12903225421905518, 0.032258063554763794, 0.16129031777381897], [0.17741934955120087, 0.17741934955120087, 0.032258063554763794, 0.06451612710952759, 0.09677419066429138], [1.0, 0.6774193644523621, 0.6129032373428345, 0.3709677457809448, 0.06451612710952759], [0.8064516186714172, 1.0, 0.6451612710952759, 0.5806451439857483, 0.33870968222618103], [0.774193525314331, 0.8709677457809448, 0.8387096524238586, 0.7096773982048035, 0.9354838728904724], [0.7419354915618896, 0.774193525314331, 0.8709677457809448, 0.8387096524238586, 0.7096773982048035], [0.5806451439857483, 0.4516128897666931, 0.4838709533214569, 0.6774193644523621, 0.7096773982048035], [0.5161290168762207, 0.5806451439857483, 0.4516128897666931, 0.4838709533214569, 0.6774193644523621], [0.24193547666072845, 0.5161290168762207, 0.5806451439857483, 0.4516128897666931, 0.4838709533214569], [0.24193547666072845, 0.29032257199287415, 0.24193547666072845, 0.4516128897666931, 0.5161290168762207], [0.06451612710952759, 0.032258063554763794, 0.12903225421905518, 0.19354838132858276, 0.22580644488334656], [0.16129031777381897, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794, 0.12903225421905518], [0.16129031777381897, 0.12903225421905518, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759], [0.16129031777381897, 0.12903225421905518, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794], [0.16129031777381897, 0.12903225421905518, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794], [0.29032257199287415, 0.16129031777381897, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794], [0.12903225421905518, 0.06451612710952759, 0.09677419066429138, 0.032258063554763794, 0.16129031777381897], [0.22580644488334656, 0.14516128599643707, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794], [0.24193547666072845, 0.08064515888690948, 0.16129031777381897, 0.08064515888690948, 0.032258063554763794], [0.3870967626571655, 0.29032257199287415, 0.20967741310596466, 0.032258063554763794, 0.09677419066429138], [0.19354838132858276, 0.032258063554763794, 0.35483869910240173, 0.30645161867141724, 0.5161290168762207], [0.5161290168762207, 0.19354838132858276, 0.032258063554763794, 0.3870967626571655, 0.30645161867141724], [0.6290322542190552, 0.7096773982048035, 0.5806451439857483, 0.7419354915618896, 0.35483869910240173], [0.5161290168762207, 0.8064516186714172, 0.6612903475761414, 0.7419354915618896, 0.6129032373428345], [0.9032257795333862, 0.9677419066429138, 1.0, 0.8064516186714172, 0.6451612710952759], [0.774193525314331, 0.9032257795333862, 0.9677419066429138, 1.0, 0.8064516186714172], [1.0, 0.9032257795333862, 0.9354838728904724, 0.8709677457809448, 0.9677419066429138], [0.6129032373428345, 0.4193548262119293, 0.5806451439857483, 1.0, 0.9677419066429138], [0.9032257795333862, 0.5483871102333069, 0.5967742204666138, 0.774193525314331, 0.6774193644523621], [0.7419354915618896, 0.8387096524238586, 0.9032257795333862, 0.6129032373428345, 0.6612903475761414], [0.8709677457809448, 0.9032257795333862, 0.9354838728904724, 0.9677419066429138, 1.0], [0.8709677457809448, 0.9032257795333862, 0.9354838728904724, 0.9677419066429138, 1.0], [0.774193525314331, 0.8064516186714172, 0.9354838728904724, 0.9677419066429138, 1.0], [0.9677419066429138, 1.0, 0.9354838728904724, 0.8709677457809448, 0.9032257795333862], [0.9032257795333862, 0.8709677457809448, 0.9354838728904724, 0.9677419066429138, 1.0], [0.7419354915618896, 0.8709677457809448, 0.9354838728904724, 0.9677419066429138, 1.0], [0.8709677457809448, 0.8387096524238586, 0.8064516186714172, 0.9354838728904724, 1.0], [1.0, 0.9032257795333862, 0.8709677457809448, 0.8387096524238586, 0.9677419066429138], [0.3870967626571655, 0.5483871102333069, 0.8387096524238586, 0.9677419066429138, 1.0], [0.20967741310596466, 0.09677419066429138, 0.3870967626571655, 0.5483871102333069, 0.9032257795333862], [0.9677419066429138, 0.7580645084381104, 0.16129031777381897, 0.29032257199287415, 0.4838709533214569], [0.19354838132858276, 0.9354838728904724, 0.725806474685669, 0.16129031777381897, 0.29032257199287415], [0.29032257199287415, 0.25806450843811035, 0.32258063554763794, 0.16129031777381897, 0.8387096524238586], [0.3709677457809448, 0.27419355511665344, 0.5161290168762207, 0.27419355511665344, 0.7096773982048035], [0.8064516186714172, 0.774193525314331, 0.6290322542190552, 0.33870968222618103, 0.25806450843811035], [0.4838709533214569, 0.35483869910240173, 0.4193548262119293, 0.3870967626571655, 0.6774193644523621], [0.29032257199287415, 0.3870967626571655, 0.4516128897666931, 0.4193548262119293, 0.35483869910240173], [0.9354838728904724, 0.9677419066429138, 0.25806450843811035, 0.19354838132858276, 0.06451612710952759], [0.5161290168762207, 0.8387096524238586, 0.6451612710952759, 0.5161290168762207, 0.5161290168762207], [0.4032258093357086, 0.4516128897666931, 0.5806451439857483, 0.4032258093357086, 0.32258063554763794], [0.14516128599643707, 0.32258063554763794, 0.5161290168762207, 0.4032258093357086, 0.4838709533214569], [0.032258063554763794, 0.14516128599643707, 0.32258063554763794, 0.5161290168762207, 0.4354838728904724], [0.06451612710952759, 0.032258063554763794, 0.14516128599643707, 0.32258063554763794, 0.5161290168762207], [0.22580644488334656, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794, 0.14516128599643707], [0.5806451439857483, 0.4838709533214569, 0.3870967626571655, 0.12903225421905518, 0.032258063554763794], [0.9677419066429138, 0.9354838728904724, 0.8225806355476379, 0.7096773982048035, 0.5483871102333069], [0.8064516186714172, 0.8387096524238586, 0.8709677457809448, 0.9677419066429138, 0.9354838728904724], [0.725806474685669, 0.774193525314331, 0.8064516186714172, 0.8387096524238586, 0.8709677457809448], [0.6451612710952759, 0.725806474685669, 0.774193525314331, 0.8064516186714172, 0.8387096524238586], [0.09677419066429138, 0.5483871102333069, 0.32258063554763794, 0.6451612710952759, 0.725806474685669], [0.032258063554763794, 0.06451612710952759, 0.09677419066429138, 0.5483871102333069, 0.32258063554763794], [0.12903225421905518, 0.032258063554763794, 0.06451612710952759, 0.09677419066429138, 0.5161290168762207], [0.22580644488334656, 0.12903225421905518, 0.032258063554763794, 0.06451612710952759, 0.09677419066429138], [0.4838709533214569, 0.4516128897666931, 0.22580644488334656, 0.09677419066429138, 0.17741934955120087], [0.17741934955120087, 0.17741934955120087, 0.32258063554763794, 0.25806450843811035, 0.35483869910240173], [0.12903225421905518, 0.22580644488334656, 0.25806450843811035, 0.17741934955120087, 0.17741934955120087], [0.09677419066429138, 0.032258063554763794, 0.12903225421905518, 0.16129031777381897, 0.19354838132858276], [0.35483869910240173, 0.06451612710952759, 0.09677419066429138, 0.032258063554763794, 0.12903225421905518], [0.22580644488334656, 0.35483869910240173, 0.06451612710952759, 0.09677419066429138, 0.032258063554763794], [0.3870967626571655, 0.12903225421905518, 0.16129031777381897, 0.32258063554763794, 0.032258063554763794], [0.9032257795333862, 1.0, 0.8709677457809448, 0.8387096524238586, 0.9677419066429138], [0.8387096524238586, 0.9354838728904724, 1.0, 0.9032257795333862, 0.8709677457809448], [0.9677419066429138, 0.8709677457809448, 0.9354838728904724, 1.0, 0.9032257795333862], [0.8709677457809448, 0.9677419066429138, 0.9032257795333862, 0.9354838728904724, 1.0], [0.8064516186714172, 0.8709677457809448, 0.9354838728904724, 0.9677419066429138, 1.0], [0.774193525314331, 0.7419354915618896, 0.9032257795333862, 0.9354838728904724, 1.0], [0.8709677457809448, 0.8064516186714172, 0.774193525314331, 0.9354838728904724, 0.9677419066429138], [0.8064516186714172, 0.9032257795333862, 0.9354838728904724, 0.9677419066429138, 1.0], [0.7419354915618896, 0.8387096524238586, 0.9354838728904724, 0.9677419066429138, 1.0], [0.6935483813285828, 0.774193525314331, 0.8709677457809448, 0.9677419066429138, 1.0], [0.4193548262119293, 0.5806451439857483, 0.8387096524238586, 0.7419354915618896, 0.7903226017951965], [0.5806451439857483, 0.5483871102333069, 0.4838709533214569, 0.6451612710952759, 0.8387096524238586], [0.8387096524238586, 1.0, 0.9032257795333862, 0.6451612710952759, 0.6774193644523621], [0.7419354915618896, 0.8709677457809448, 0.9354838728904724, 1.0, 0.9032257795333862], [1.0, 0.8870967626571655, 0.8064516186714172, 0.9354838728904724, 0.9677419066429138], [0.774193525314331, 0.7096773982048035, 0.8709677457809448, 1.0, 0.9677419066429138], [0.9677419066429138, 0.9354838728904724, 1.0, 0.8064516186714172, 0.8709677457809448], [0.8387096524238586, 0.9032257795333862, 0.9354838728904724, 0.9677419066429138, 1.0], [0.9032257795333862, 0.8064516186714172, 0.8709677457809448, 0.9354838728904724, 1.0], [0.8709677457809448, 0.9354838728904724, 0.8387096524238586, 0.9032257795333862, 0.9677419066429138], [1.0, 0.9032257795333862, 0.9677419066429138, 0.8709677457809448, 0.9354838728904724], [1.0, 0.12903225421905518, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794], [0.8387096524238586, 0.9032257795333862, 0.9354838728904724, 0.9677419066429138, 1.0], [0.9032257795333862, 0.8709677457809448, 0.9354838728904724, 0.9677419066429138, 1.0], [0.7903226017951965, 0.25806450843811035, 0.14516128599643707, 0.4516128897666931, 1.0], [0.6290322542190552, 0.22580644488334656, 0.6290322542190552, 0.4516128897666931, 0.7580645084381104], [0.6774193644523621, 0.35483869910240173, 0.16129031777381897, 0.09677419066429138, 0.27419355511665344], [0.16129031777381897, 0.35483869910240173, 0.4032258093357086, 0.6451612710952759, 0.5483871102333069], [0.12903225421905518, 0.032258063554763794, 0.16129031777381897, 0.35483869910240173, 0.4032258093357086], [0.09677419066429138, 0.22580644488334656, 0.06451612710952759, 0.12903225421905518, 0.032258063554763794], [0.29032257199287415, 0.06451612710952759, 0.19354838132858276, 0.032258063554763794, 0.09677419066429138], [0.14516128599643707, 0.14516128599643707, 0.29032257199287415, 0.22580644488334656, 0.19354838132858276], [0.032258063554763794, 0.19354838132858276, 0.14516128599643707, 0.14516128599643707, 0.22580644488334656], [0.4354838728904724, 0.6612903475761414, 0.29032257199287415, 0.06451612710952759, 0.032258063554763794], [0.4838709533214569, 0.3870967626571655, 0.4354838728904724, 0.6612903475761414, 0.29032257199287415], [0.6774193644523621, 0.8064516186714172, 0.7419354915618896, 0.5161290168762207, 0.6290322542190552], [0.8709677457809448, 0.6774193644523621, 0.8064516186714172, 0.7419354915618896, 0.5483871102333069], [0.774193525314331, 0.9677419066429138, 0.8709677457809448, 0.7096773982048035, 0.8064516186714172], [0.8709677457809448, 0.9032257795333862, 1.0, 0.8387096524238586, 0.9677419066429138], [0.725806474685669, 0.9677419066429138, 0.9032257795333862, 0.9354838728904724, 1.0], [0.8225806355476379, 0.9677419066429138, 0.5806451439857483, 0.8225806355476379, 1.0], [0.8064516186714172, 0.9354838728904724, 0.9677419066429138, 1.0, 0.8709677457809448], [0.9032257795333862, 0.8387096524238586, 0.9354838728904724, 0.9677419066429138, 1.0], [0.6129032373428345, 0.8709677457809448, 0.9677419066429138, 0.9032257795333862, 1.0], [0.9032257795333862, 0.8709677457809448, 0.6774193644523621, 0.9354838728904724, 1.0], [1.0, 0.9354838728904724, 0.9032257795333862, 0.7096773982048035, 0.9677419066429138], [0.9677419066429138, 0.8064516186714172, 0.5806451439857483, 0.774193525314331, 0.8387096524238586], [1.0, 0.9677419066429138, 0.8387096524238586, 0.6129032373428345, 0.8064516186714172], [0.9354838728904724, 1.0, 0.9677419066429138, 0.8387096524238586, 0.6451612710952759], [0.6451612710952759, 0.8387096524238586, 0.9354838728904724, 0.9677419066429138, 1.0], [0.9354838728904724, 1.0, 0.9677419066429138, 0.8387096524238586, 0.8064516186714172], [0.7096773982048035, 0.774193525314331, 0.9032257795333862, 0.9677419066429138, 1.0], [0.6774193644523621, 0.7096773982048035, 0.774193525314331, 0.8387096524238586, 0.9677419066429138], [0.9516128897666931, 0.7096773982048035, 0.7419354915618896, 0.8064516186714172, 0.8709677457809448], [0.4354838728904724, 0.5806451439857483, 0.6774193644523621, 0.7096773982048035, 0.7419354915618896], [0.32258063554763794, 0.29032257199287415, 0.6129032373428345, 0.4354838728904724, 0.5806451439857483], [0.19354838132858276, 0.09677419066429138, 0.32258063554763794, 0.29032257199287415, 0.5483871102333069], [0.22580644488334656, 0.35483869910240173, 0.19354838132858276, 0.09677419066429138, 0.29032257199287415], [0.32258063554763794, 0.29032257199287415, 0.4193548262119293, 0.16129031777381897, 0.25806450843811035], [0.16129031777381897, 0.12903225421905518, 0.25806450843811035, 0.22580644488334656, 0.35483869910240173], [0.19354838132858276, 0.16129031777381897, 0.12903225421905518, 0.25806450843811035, 0.22580644488334656], [0.29032257199287415, 0.19354838132858276, 0.16129031777381897, 0.12903225421905518, 0.22580644488334656], [0.06451612710952759, 0.032258063554763794, 0.09677419066429138, 0.19354838132858276, 0.12903225421905518], [0.12903225421905518, 0.06451612710952759, 0.032258063554763794, 0.09677419066429138, 0.16129031777381897], [0.16129031777381897, 0.12903225421905518, 0.06451612710952759, 0.032258063554763794, 0.09677419066429138], [0.12903225421905518, 0.16129031777381897, 0.09677419066429138, 0.06451612710952759, 0.032258063554763794], [0.19354838132858276, 0.12903225421905518, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759], [0.16129031777381897, 0.09677419066429138, 0.12903225421905518, 0.06451612710952759, 0.032258063554763794], [0.12903225421905518, 0.16129031777381897, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759], [0.16129031777381897, 0.12903225421905518, 0.06451612710952759, 0.09677419066429138, 0.032258063554763794], [0.22580644488334656, 0.12903225421905518, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759], [1.0, 0.8387096524238586, 0.9516128897666931, 0.8709677457809448, 0.9516128897666931], [0.8870967626571655, 0.6451612710952759, 0.7096773982048035, 0.5483871102333069, 0.6129032373428345], [0.8387096524238586, 1.0, 0.8870967626571655, 0.6451612710952759, 0.7096773982048035], [0.032258063554763794, 0.25806450843811035, 0.5483871102333069, 0.5806451439857483, 0.5161290168762207], [0.5322580933570862, 0.774193525314331, 0.25806450843811035, 0.06451612710952759, 0.032258063554763794], [0.12903225421905518, 0.06451612710952759, 0.09677419066429138, 0.29032257199287415, 0.32258063554763794], [0.19354838132858276, 0.16129031777381897, 0.29032257199287415, 0.04838709533214569, 0.04838709533214569], [0.3870967626571655, 0.29032257199287415, 0.09677419066429138, 0.16129031777381897, 0.12903225421905518], [0.4354838728904724, 0.25806450843811035, 0.22580644488334656, 0.4838709533214569, 0.3870967626571655], [0.5161290168762207, 0.4354838728904724, 0.29032257199287415, 0.25806450843811035, 0.4838709533214569], [0.9677419066429138, 0.9354838728904724, 0.8387096524238586, 0.5806451439857483, 0.6451612710952759], [0.774193525314331, 0.8709677457809448, 0.9032257795333862, 1.0, 0.9677419066429138], [0.5161290168762207, 0.4516128897666931, 0.5483871102333069, 0.32258063554763794, 0.25806450843811035], [0.12903225421905518, 0.16129031777381897, 0.09677419066429138, 0.032258063554763794, 0.06451612710952759], [0.19354838132858276, 0.22580644488334656, 0.16129031777381897, 0.032258063554763794, 0.06451612710952759], [0.19354838132858276, 0.032258063554763794, 0.06451612710952759, 0.09677419066429138, 0.12903225421905518], [0.19354838132858276, 0.16129031777381897, 0.032258063554763794, 0.06451612710952759, 0.09677419066429138], [0.22580644488334656, 0.16129031777381897, 0.12903225421905518, 0.032258063554763794, 0.06451612710952759], [0.5161290168762207, 0.32258063554763794, 0.4193548262119293, 0.25806450843811035, 0.3870967626571655], [0.9677419066429138, 0.8709677457809448, 0.6451612710952759, 0.4838709533214569, 0.5161290168762207], [0.6774193644523621, 0.774193525314331, 0.8387096524238586, 0.8064516186714172, 0.8709677457809448], [0.4516128897666931, 0.5161290168762207, 0.5483871102333069, 0.6774193644523621, 0.774193525314331], [0.032258063554763794, 0.12903225421905518, 0.09677419066429138, 0.19354838132858276, 0.16129031777381897], [0.06451612710952759, 0.032258063554763794, 0.12903225421905518, 0.09677419066429138, 0.16129031777381897], [0.25806450843811035, 0.16129031777381897, 0.06451612710952759, 0.032258063554763794, 0.09677419066429138], [0.9032257795333862, 0.5161290168762207, 0.6774193644523621, 0.8225806355476379, 0.9677419066429138], [0.9677419066429138, 0.9354838728904724, 0.5483871102333069, 0.7096773982048035, 0.8548387289047241]]
).astype(np.float32)

query = np.array([0.9677419, 0.9032258, 0.5483871, 0.58064514, 0.6451613]).astype(np.float32)

maxDistance = 0.07331936806440353

sa = subsequence_search(query, series, dists_options = {'use_c': True, 'max_dist': maxDistance})

best = sa.kbest_matches_fast(k = None)

print(len(list(best)))

results = list(filter(lambda r: r.idx != -1 and r.distance <= maxDistance, best))

assert len(results) == 1

print(f'Works, we got {len(results)} result!')

This is confirmed to be working at commit 26c39622a269cd2bff9ddc42683b21ae3b2533e5

But it is not working one commit later at 31f77034bd7687cbcb2820be008065bd8d1d6ff8

If you do print(len(list(best))) at this broken commit, you'll see there's only 1 item, with a distance of infinity and an idx of -1. Yet in the test data above there is exactly one series with a distance less than the maxDistance. If you change k = None to a positive integer, it does seem to work.

wannesm commented 1 year ago

You are right, a line went missing and corrupted the output. Fixed in 1e73305.