@@ -50,16 +50,16 @@ class _stimp:
50
50
T : numpy.ndarray
51
51
The time series or sequence for which to compute the pan matrix profile
52
52
53
- m_start : int, default 3
53
+ min_m : int, default 3
54
54
The starting (or minimum) subsequence window size for which a matrix profile
55
55
may be computed
56
56
57
- m_stop : int, default None
57
+ max_m : int, default None
58
58
The stopping (or maximum) subsequence window size for which a matrix profile
59
- may be computed. When `m_stop = Non`, this is set to the maximum allowable
59
+ may be computed. When `max_m = Non`, this is set to the maximum allowable
60
60
subsequence window size
61
61
62
- m_step : int, default 1
62
+ step : int, default 1
63
63
The step between subsequence window sizes
64
64
65
65
percentage : float, default 0.01
@@ -87,6 +87,14 @@ class _stimp:
87
87
mp_func : function, default stump
88
88
The matrix profile function to use when `percentage = 1.0`
89
89
90
+ T_subseq_isconstant_func : function, default None
91
+ A custom, user-defined function that returns a boolean array that indicates
92
+ whether a subsequence in `T` is constant (True). The function must only take
93
+ two arguments, `a`, a 1-D array, and `w`, the window size, while additional
94
+ arguments may be specified by currying the user-defined function using
95
+ `functools.partial`. Any subsequence with at least one np.nan/np.inf will
96
+ automatically have its corresponding value set to False in this boolean array.
97
+
90
98
Attributes
91
99
----------
92
100
PAN_ : numpy.ndarray
@@ -122,6 +130,7 @@ def __init__(
122
130
client = None ,
123
131
device_id = None ,
124
132
mp_func = stump ,
133
+ T_subseq_isconstant_func = None ,
125
134
):
126
135
"""
127
136
Initialize the `stimp` object and compute the Pan Matrix Profile
@@ -167,6 +176,15 @@ def __init__(
167
176
168
177
mp_func : function, default stump
169
178
The matrix profile function to use when `percentage = 1.0`
179
+
180
+ T_subseq_isconstant_func : function, default None
181
+ A custom, user-defined function that returns a boolean array that indicates
182
+ whether a subsequence in `T` is constant (True). The function must only take
183
+ two arguments, `a`, a 1-D array, and `w`, the window size, while additional
184
+ arguments may be specified by currying the user-defined function using
185
+ `functools.partial`. Any subsequence with at least one np.nan/np.inf will
186
+ automatically have its corresponding value set to False in this boolean
187
+ array.
170
188
"""
171
189
self ._T = T .copy ()
172
190
if max_m is None :
@@ -189,6 +207,16 @@ def __init__(
189
207
mp_func , client = client , device_id = device_id
190
208
)
191
209
210
+ if T_subseq_isconstant_func is None :
211
+ T_subseq_isconstant_func = core ._rolling_isconstant
212
+ if not callable (T_subseq_isconstant_func ): # pragma: no cover
213
+ msg = (
214
+ "`T_subseq_isconstant_func` was expected to be a callable function "
215
+ + f"but { type (T_subseq_isconstant_func )} was found."
216
+ )
217
+ raise ValueError (msg )
218
+ self ._T_subseq_isconstant_func = T_subseq_isconstant_func
219
+
192
220
self ._PAN = np .full (
193
221
(self ._M .shape [0 ], self ._T .shape [0 ]), fill_value = np .inf , dtype = np .float64
194
222
)
@@ -223,6 +251,7 @@ def update(self):
223
251
percentage = self ._percentage ,
224
252
pre_scrump = self ._pre_scrump ,
225
253
k = 1 ,
254
+ T_A_subseq_isconstant = self ._T_subseq_isconstant_func ,
226
255
)
227
256
approx .update ()
228
257
self ._PAN [
@@ -233,6 +262,7 @@ def update(self):
233
262
self ._T ,
234
263
m ,
235
264
ignore_trivial = True ,
265
+ T_A_subseq_isconstant = self ._T_subseq_isconstant_func ,
236
266
)
237
267
self ._PAN [
238
268
self ._bfs_indices [self ._n_processed ], : out [:, 0 ].shape [0 ]
@@ -347,7 +377,7 @@ def M_(self):
347
377
348
378
@core .non_normalized (
349
379
aamp_stimp ,
350
- exclude = ["pre_scrump" , "normalize" , "p" , "pre_scraamp" ],
380
+ exclude = ["pre_scrump" , "normalize" , "p" , "T_subseq_isconstant_func" , " pre_scraamp" ],
351
381
replace = {"pre_scrump" : "pre_scraamp" },
352
382
)
353
383
class stimp (_stimp ):
@@ -361,16 +391,16 @@ class stimp(_stimp):
361
391
T : numpy.ndarray
362
392
The time series or sequence for which to compute the pan matrix profile
363
393
364
- m_start : int, default 3
394
+ min_m : int, default 3
365
395
The starting (or minimum) subsequence window size for which a matrix profile
366
396
may be computed
367
397
368
- m_stop : int, default None
398
+ max_m : int, default None
369
399
The stopping (or maximum) subsequence window size for which a matrix profile
370
- may be computed. When `m_stop = Non`, this is set to the maximum allowable
400
+ may be computed. When `max_m = Non`, this is set to the maximum allowable
371
401
subsequence window size
372
402
373
- m_step : int, default 1
403
+ step : int, default 1
374
404
The step between subsequence window sizes
375
405
376
406
percentage : float, default 0.01
@@ -393,6 +423,14 @@ class stimp(_stimp):
393
423
The p-norm to apply for computing the Minkowski distance. This parameter is
394
424
ignored when `normalize == True`.
395
425
426
+ T_subseq_isconstant_func : function, default None
427
+ A custom, user-defined function that returns a boolean array that indicates
428
+ whether a subsequence in `T` is constant (True). The function must only take
429
+ two arguments, `a`, a 1-D array, and `w`, the window size, while additional
430
+ arguments may be specified by currying the user-defined function using
431
+ `functools.partial`. Any subsequence with at least one np.nan/np.inf will
432
+ automatically have its corresponding value set to False in this boolean array.
433
+
396
434
Attributes
397
435
----------
398
436
PAN_ : numpy.ndarray
@@ -442,6 +480,7 @@ def __init__(
442
480
pre_scrump = True ,
443
481
normalize = True ,
444
482
p = 2.0 ,
483
+ T_subseq_isconstant_func = None ,
445
484
):
446
485
"""
447
486
Initialize the `stimp` object and compute the Pan Matrix Profile
@@ -483,6 +522,15 @@ def __init__(
483
522
p : float, default 2.0
484
523
The p-norm to apply for computing the Minkowski distance. This parameter is
485
524
ignored when `normalize == True`.
525
+
526
+ T_subseq_isconstant_func : function, default None
527
+ A custom, user-defined function that returns a boolean array that indicates
528
+ whether a subsequence in `T` is constant (True). The function must only take
529
+ two arguments, `a`, a 1-D array, and `w`, the window size, while additional
530
+ arguments may be specified by currying the user-defined function using
531
+ `functools.partial`. Any subsequence with at least one np.nan/np.inf will
532
+ automatically have its corresponding value set to False in this boolean
533
+ array.
486
534
"""
487
535
super ().__init__ (
488
536
T ,
@@ -492,12 +540,13 @@ def __init__(
492
540
percentage = percentage ,
493
541
pre_scrump = pre_scrump ,
494
542
mp_func = stump ,
543
+ T_subseq_isconstant_func = T_subseq_isconstant_func ,
495
544
)
496
545
497
546
498
547
@core .non_normalized (
499
548
aamp_stimped ,
500
- exclude = ["pre_scrump" , "normalize" , "p" , "pre_scraamp" ],
549
+ exclude = ["pre_scrump" , "normalize" , "p" , "T_subseq_isconstant_func" , " pre_scraamp" ],
501
550
replace = {"pre_scrump" : "pre_scraamp" },
502
551
)
503
552
class stimped (_stimp ):
@@ -516,16 +565,16 @@ class stimped(_stimp):
516
565
T : numpy.ndarray
517
566
The time series or sequence for which to compute the pan matrix profile
518
567
519
- m_start : int, default 3
568
+ min_m : int, default 3
520
569
The starting (or minimum) subsequence window size for which a matrix profile
521
570
may be computed
522
571
523
- m_stop : int, default None
572
+ max_m : int, default None
524
573
The stopping (or maximum) subsequence window size for which a matrix profile
525
- may be computed. When `m_stop = Non`, this is set to the maximum allowable
574
+ may be computed. When `max_m = Non`, this is set to the maximum allowable
526
575
subsequence window size
527
576
528
- m_step : int, default 1
577
+ step : int, default 1
529
578
The step between subsequence window sizes
530
579
531
580
normalize : bool, default True
@@ -537,6 +586,15 @@ class stimped(_stimp):
537
586
The p-norm to apply for computing the Minkowski distance. This parameter is
538
587
ignored when `normalize == True`.
539
588
589
+ T_subseq_isconstant_func : function, default None
590
+ A custom, user-defined function that returns a boolean array that indicates
591
+ whether a subsequence in `T` is constant (True). The function must only take
592
+ two arguments, `a`, a 1-D array, and `w`, the window size, while additional
593
+ arguments may be specified by currying the user-defined function using
594
+ `functools.partial`. Any subsequence with at least one np.nan/np.inf will
595
+ automatically have its corresponding value set to False in this boolean
596
+ array.
597
+
540
598
Attributes
541
599
----------
542
600
PAN_ : numpy.ndarray
@@ -590,6 +648,7 @@ def __init__(
590
648
step = 1 ,
591
649
normalize = True ,
592
650
p = 2.0 ,
651
+ T_subseq_isconstant_func = None ,
593
652
):
594
653
"""
595
654
Initialize the `stimp` object and compute the Pan Matrix Profile
@@ -625,6 +684,15 @@ def __init__(
625
684
p : float, default 2.0
626
685
The p-norm to apply for computing the Minkowski distance. This parameter is
627
686
ignored when `normalize == True`.
687
+
688
+ T_subseq_isconstant_func : function, default None
689
+ A custom, user-defined function that returns a boolean array that indicates
690
+ whether a subsequence in `T` is constant (True). The function must only take
691
+ two arguments, `a`, a 1-D array, and `w`, the window size, while additional
692
+ arguments may be specified by currying the user-defined function using
693
+ `functools.partial`. Any subsequence with at least one np.nan/np.inf will
694
+ automatically have its corresponding value set to False in this boolean
695
+ array.
628
696
"""
629
697
super ().__init__ (
630
698
T ,
@@ -635,4 +703,5 @@ def __init__(
635
703
pre_scrump = False ,
636
704
client = client ,
637
705
mp_func = stumped ,
706
+ T_subseq_isconstant_func = T_subseq_isconstant_func ,
638
707
)
0 commit comments