Skip to content

Commit 231ccb1

Browse files
committed
Fixed #227 Warn users that inputs must be float
1 parent cbb5443 commit 231ccb1

27 files changed

+89
-46
lines changed

stumpy/aamp.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,6 @@ def aamp(T_A, m, T_B=None, ignore_trivial=True):
279279
if T_B.ndim != 1: # pragma: no cover
280280
raise ValueError(f"T_B is {T_B.ndim}-dimensional and must be 1-dimensional. ")
281281

282-
core.check_dtype(T_A)
283-
core.check_dtype(T_B)
284-
285282
core.check_window_size(m)
286283

287284
if ignore_trivial is False and core.are_arrays_equal(T_A, T_B): # pragma: no cover

stumpy/aamped.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ def aamped(dask_client, T_A, m, T_B=None, ignore_trivial=True):
6969
if T_B.ndim != 1: # pragma: no cover
7070
raise ValueError(f"T_B is {T_B.ndim}-dimensional and must be 1-dimensional. ")
7171

72-
core.check_dtype(T_A)
73-
core.check_dtype(T_B)
74-
7572
core.check_window_size(m)
7673

7774
if ignore_trivial is False and core.are_arrays_equal(T_A, T_B): # pragma: no cover

stumpy/aampi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ def __init__(self, T, m, excl_zone=None, egress=True):
8080
If set to `True`, the oldest data point in the time series is removed and
8181
the time series length remains constant rather than forever increasing
8282
"""
83-
self._T = np.asarray(T)
83+
self._T = T.copy()
84+
self._T = np.asarray(self._T)
85+
core.check_dtype(self._T)
8486
self._m = m
8587
self._n = self._T.shape[0]
8688
if excl_zone is not None: # pragma: no cover

stumpy/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def check_dtype(a, dtype=np.floating): # pragma: no cover
118118
If the array type does not match `dtype`
119119
"""
120120
if not np.issubdtype(a.dtype, dtype):
121-
msg = f"{dtype} type expected but found {a.dtype}"
121+
msg = f"{dtype} type expected but found {a.dtype}\n"
122+
msg += "Please change your input `dtype` with `.astype(float)`"
122123
raise TypeError(msg)
123124

124125
return True
@@ -852,6 +853,7 @@ def preprocess(T, m):
852853
"""
853854
T = T.copy()
854855
T = np.asarray(T)
856+
check_dtype(T)
855857

856858
T[np.isinf(T)] = np.nan
857859
M_T, Σ_T = compute_mean_std(T, m)
@@ -889,6 +891,7 @@ def preprocess_non_normalized(T, m):
889891
"""
890892
T = T.copy()
891893
T = np.asarray(T)
894+
check_dtype(T)
892895

893896
T[np.isinf(T)] = np.nan
894897
T_subseq_isfinite = np.all(np.isfinite(rolling_window(T, m)), axis=1)

stumpy/gpu_aamp.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,6 @@ def gpu_aamp(T_A, m, T_B=None, ignore_trivial=True, device_id=0):
437437
"For multidimensional STUMP use `stumpy.mstump` or `stumpy.mstumped`"
438438
)
439439

440-
core.check_dtype(T_A)
441-
core.check_dtype(T_B)
442-
443440
core.check_window_size(m)
444441

445442
if ignore_trivial is False and core.are_arrays_equal(T_A, T_B): # pragma: no cover

stumpy/gpu_stump.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,6 @@ def gpu_stump(T_A, m, T_B=None, ignore_trivial=True, device_id=0):
461461
"For multidimensional STUMP use `stumpy.mstump` or `stumpy.mstumped`"
462462
)
463463

464-
core.check_dtype(T_A)
465-
core.check_dtype(T_B)
466-
467464
core.check_window_size(m)
468465

469466
if ignore_trivial is False and core.are_arrays_equal(T_A, T_B): # pragma: no cover

stumpy/mstump.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,6 @@ def mstump(T, m, include=None, discords=False):
619619
err = f"T is {T_A.ndim}-dimensional and must be at least 1-dimensional"
620620
raise ValueError(f"{err}")
621621

622-
core.check_dtype(T_A)
623-
core.check_dtype(T_B)
624-
625622
core.check_window_size(m)
626623

627624
if include is not None:

stumpy/mstumped.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ def mstumped(dask_client, T, m, include=None, discords=False):
8080
err = f"T is {T_A.ndim}-dimensional and must be at least 1-dimensional"
8181
raise ValueError(f"{err}")
8282

83-
core.check_dtype(T_A)
84-
core.check_dtype(T_B)
85-
8683
core.check_window_size(m)
8784

8885
if include is not None:

stumpy/scrump.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,21 @@ def prescrump(T_A, m, T_B=None, s=None):
180180
181181
See Algorithm 2
182182
"""
183-
T_A = np.asarray(T_A)
184183
T_A = T_A.copy()
185-
T_A[np.isinf(T_A)] = np.nan
184+
T_A = np.asarray(T_A)
186185
core.check_dtype(T_A)
186+
T_A[np.isinf(T_A)] = np.nan
187187

188188
if T_B is None:
189189
T_B = T_A
190190
excl_zone = int(np.ceil(m / 4))
191191
else:
192192
excl_zone = None
193193

194-
T_B = np.asarray(T_B)
195194
T_B = T_B.copy()
196-
T_B[np.isinf(T_B)] = np.nan
195+
T_B = np.asarray(T_B)
197196
core.check_dtype(T_B)
197+
T_B[np.isinf(T_B)] = np.nan
198198

199199
core.check_window_size(m)
200200

@@ -376,9 +376,6 @@ def __init__(
376376
"For multidimensional STUMP use `stumpy.mstump` or `stumpy.mstumped`"
377377
)
378378

379-
core.check_dtype(self._T_A)
380-
core.check_dtype(self._T_B)
381-
382379
core.check_window_size(self._m)
383380

384381
if self._ignore_trivial is False and core.are_arrays_equal(

stumpy/stamp.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ def stamp(T_A, T_B, m, ignore_trivial=False):
136136
if T_B.ndim != 1: # pragma: no cover
137137
raise ValueError(f"T_B is {T_B.ndim}-dimensional and must be 1-dimensional. ")
138138

139-
core.check_dtype(T_A)
140-
core.check_dtype(T_B)
141-
142139
core.check_window_size(m)
143140
subseq_T_B = core.rolling_window(T_B, m)
144141
excl_zone = int(np.ceil(m / 2))

0 commit comments

Comments
 (0)