@@ -247,15 +247,20 @@ def are_distances_too_small(a, threshold=10e-6): # pragma: no cover
247247 return False
248248
249249
250- def check_window_size (m ):
250+ def check_window_size (m , max_size = None ):
251251 """
252- Check the window size and ensure that it is greater than or equal to 3
252+ Check the window size and ensure that it is greater than or equal to 3 and, if
253+ `max_size` is provided, ensure that the window size is less than or equal to the
254+ `max_size`
253255
254256 Parameters
255257 ----------
256258 m : int
257259 Window size
258260
261+ max_size : int, default None
262+ The maximum window size allowed
263+
259264 Returns
260265 -------
261266 None
@@ -274,6 +279,9 @@ def check_window_size(m):
274279 """ ,
275280 )
276281
282+ if max_size is not None and m > max_size :
283+ raise ValueError (f"The window size must be less than or equal to { max_size } " )
284+
277285
278286def sliding_dot_product (Q , T ):
279287 """
@@ -979,6 +987,12 @@ def mass(Q, T, M_T=None, Σ_T=None):
979987 if T .ndim != 1 : # pragma: no cover
980988 raise ValueError (f"T is { T .ndim } -dimensional and must be 1-dimensional. " )
981989
990+ if m > n : # pragma: no cover
991+ raise ValueError (
992+ f"The length of `Q` ({ len (Q )} ) must be less than or equal to "
993+ f"the length of `T` ({ len (T )} ). "
994+ )
995+
982996 distance_profile = np .empty (n - m + 1 )
983997 if np .any (~ np .isfinite (Q )):
984998 distance_profile [:] = np .inf
@@ -1104,6 +1118,12 @@ def mass_absolute(Q, T):
11041118 if T .ndim != 1 : # pragma: no cover
11051119 raise ValueError (f"T is { T .ndim } -dimensional and must be 1-dimensional. " )
11061120
1121+ if m > n : # pragma: no cover
1122+ raise ValueError (
1123+ f"The length of `Q` ({ len (Q )} ) must be less than or equal to "
1124+ f"the length of `T` ({ len (T )} ). "
1125+ )
1126+
11071127 distance_profile = np .empty (n - m + 1 )
11081128 if np .any (~ np .isfinite (Q )):
11091129 distance_profile [:] = np .inf
0 commit comments