File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,26 @@ def _convolve_sliding_dot_product(Q, T):
5555 return convolve (np .flipud (Q ), T , mode = "valid" )
5656
5757
58+ def _oaconvolve_sliding_dot_product (Q , T ):
59+ """
60+ Use scipy's oaconvolve to calculate the sliding dot product.
61+
62+ Parameters
63+ ----------
64+ Q : numpy.ndarray
65+ Query array or subsequence
66+
67+ T : numpy.ndarray
68+ Time series or sequence
69+
70+ Returns
71+ -------
72+ output : numpy.ndarray
73+ Sliding dot product between `Q` and `T`.
74+ """
75+ return oaconvolve (np .ascontiguousarray (Q [::- 1 ]), T , mode = "valid" )
76+
77+
5878def _sliding_dot_product (Q , T ):
5979 """
6080 Compute the sliding dot product between `Q` and `T`
Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ def test_convolve_sliding_dot_product(Q, T):
2929 npt .assert_almost_equal (ref_mp , comp_mp )
3030
3131
32+ @pytest .mark .parametrize ("Q, T" , test_data )
33+ def test_oaconvolve_sliding_dot_product (Q , T ):
34+ ref_mp = naive .rolling_window_dot_product (Q , T )
35+ comp_mp = sdp ._convolve_sliding_dot_product (Q , T )
36+ npt .assert_almost_equal (ref_mp , comp_mp )
37+
38+
3239@pytest .mark .parametrize ("Q, T" , test_data )
3340def test_sliding_dot_product (Q , T ):
3441 ref_mp = naive .rolling_window_dot_product (Q , T )
You can’t perform that action at this time.
0 commit comments