Skip to content

Commit fb9a125

Browse files
Fixed #1013 set param T_subseq_isconstant to default None in core.process_isconstant (#1016)
* set param to default None * test default mode of function
1 parent 121cf5d commit fb9a125

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

stumpy/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4221,7 +4221,7 @@ def _mpdist(
42214221
return MPdist
42224222

42234223

4224-
def process_isconstant(T, m, T_subseq_isconstant, T_subseq_isfinite=None):
4224+
def process_isconstant(T, m, T_subseq_isconstant=None, T_subseq_isfinite=None):
42254225
"""
42264226
A convenience wrapper around the `rolling_isconstant` and
42274227
`fix_isconstant_isfinite_conflicts`.

tests/test_core.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,3 +1753,28 @@ def test_process_isconstant_2d():
17531753
T_subseq_isconstant_comp = core.process_isconstant(T, m, T_subseq_isconstant)
17541754

17551755
npt.assert_array_equal(T_subseq_isconstant_ref, T_subseq_isconstant_comp)
1756+
1757+
1758+
def test_process_isconstant_1d_default():
1759+
# test the default value of `T_subseq_isconstant` in `process_isconstant`
1760+
n = 64
1761+
m = 8
1762+
1763+
# case 1: without nan
1764+
T = np.random.rand(n)
1765+
T[:m] = 0.5 # constant subsequence
1766+
1767+
T_subseq_isconstant_ref = naive.rolling_isconstant(T, m, a_subseq_isconstant=None)
1768+
T_subseq_isconstant_comp = core.process_isconstant(T, m, T_subseq_isconstant=None)
1769+
1770+
npt.assert_array_equal(T_subseq_isconstant_ref, T_subseq_isconstant_comp)
1771+
1772+
# case 2: with nan
1773+
T = np.random.rand(n)
1774+
T[:m] = 0.5 # constant subsequence
1775+
T[-m:] = np.nan # non-finite subsequence
1776+
1777+
T_subseq_isconstant_ref = naive.rolling_isconstant(T, m, a_subseq_isconstant=None)
1778+
T_subseq_isconstant_comp = core.process_isconstant(T, m, T_subseq_isconstant=None)
1779+
1780+
npt.assert_array_equal(T_subseq_isconstant_ref, T_subseq_isconstant_comp)

0 commit comments

Comments
 (0)