Skip to content

Commit cf56cc0

Browse files
committed
Converted all dtypes to np.float64/np.int64
1 parent 27285c0 commit cf56cc0

22 files changed

+90
-85
lines changed

stumpy/aamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ def _aamp(T_A, T_B, m, T_A_subseq_isfinite, T_B_subseq_isfinite, diags, ignore_t
182182
n_B = T_B.shape[0]
183183
l = n_A - m + 1
184184
n_threads = numba.config.NUMBA_NUM_THREADS
185-
P = np.full((n_threads, l, 3), np.inf)
186-
I = np.full((n_threads, l, 3), -1, np.int64)
185+
P = np.full((n_threads, l, 3), np.inf, dtype=np.float64)
186+
I = np.full((n_threads, l, 3), -1, dtype=np.int64)
187187

188188
ndist_counts = core._count_diagonal_ndist(diags, m, n_A, n_B)
189189
diags_ranges = core._get_array_ranges(ndist_counts, n_threads, False)

stumpy/aamp_motifs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ def _aamp_motifs(
124124
candidate_idx = np.argmin(P[-1])
125125

126126
motif_distances = core._jagged_list_to_array(
127-
motif_distances, fill_value=np.nan, dtype="float64"
127+
motif_distances, fill_value=np.nan, dtype=np.float64
128128
)
129129
motif_indices = core._jagged_list_to_array(
130-
motif_indices, fill_value=-1, dtype="int64"
130+
motif_indices, fill_value=-1, dtype=np.int64
131131
)
132132

133133
return motif_distances, motif_indices

stumpy/aamp_ostinato.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _aamp_across_series_nearest_neighbors(
5454

5555
for i in range(k):
5656
if np.any(~np.isfinite(Q)): # pragma: no cover
57-
distance_profile = np.empty(Ts[i].shape[0] - m + 1)
57+
distance_profile = np.empty(Ts[i].shape[0] - m + 1, dtype=np.float64)
5858
distance_profile[:] = np.inf
5959
else:
6060
QT = core.sliding_dot_product(

stumpy/aampdist_snippets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _get_all_aampdist_profiles(
8686
T = np.pad(T, pad_width, mode="constant", constant_values=np.nan)
8787

8888
n_padded = T.shape[0]
89-
D = np.empty(((n_padded // m) - 1, n_padded - m + 1))
89+
D = np.empty(((n_padded // m) - 1, n_padded - m + 1), dtype=np.float64)
9090

9191
if s is not None:
9292
s = min(int(s), m)
@@ -214,11 +214,11 @@ def aampdist_snippets(
214214

215215
snippets = np.empty((k, m))
216216
snippets_indices = np.empty(k, dtype=np.int64)
217-
snippets_profiles = np.empty((k, D.shape[-1]))
218-
snippets_fractions = np.empty(k)
219-
snippets_areas = np.empty(k)
220-
Q = np.full(D.shape[-1], np.inf)
221-
indices = np.arange(0, n_padded - m, m)
217+
snippets_profiles = np.empty((k, D.shape[-1]), dtype=np.float64)
218+
snippets_fractions = np.empty(k, dtype=np.float64)
219+
snippets_areas = np.empty(k, dtype=np.float64)
220+
Q = np.full(D.shape[-1], np.inf, dtype=np.float64)
221+
indices = np.arange(0, n_padded - m, m, dtype=np.int64)
222222
snippets_regimes_list = []
223223

224224
for i in range(k):

stumpy/aamped.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def aamped(dask_client, T_A, m, T_B=None, ignore_trivial=True):
113113
diags_futures = []
114114
for i, host in enumerate(hosts):
115115
diags_future = dask_client.scatter(
116-
np.arange(diags_ranges[i, 0], diags_ranges[i, 1]),
116+
np.arange(diags_ranges[i, 0], diags_ranges[i, 1], dtype=np.int64),
117117
workers=[host],
118118
hash=False,
119119
)

stumpy/aampi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(self, T, m, egress=True):
8888
self._P = mp[:, 0].astype(np.float64)
8989
self._I = mp[:, 1].astype(np.int64)
9090
self._left_I = mp[:, 2].astype(np.int64)
91-
self._left_P = np.empty(self._P.shape)
91+
self._left_P = np.empty(self._P.shape, dtype=np.float64)
9292
self._left_P[:] = np.inf
9393

9494
self._T_isfinite = np.isfinite(self._T)
@@ -110,7 +110,7 @@ def __init__(self, T, m, egress=True):
110110
Q = self._T[-m:]
111111
self._QT = core.sliding_dot_product(Q, self._T)
112112
if self._egress:
113-
self._QT_new = np.empty(self._QT.shape[0])
113+
self._QT_new = np.empty(self._QT.shape[0], dtype=np.float64)
114114
self._n_appended = 0
115115

116116
def update(self, t):
@@ -208,7 +208,7 @@ def _update(self, t):
208208
self._n = self._T.shape[0]
209209
l = self._n - self._m + 1
210210
T_new = np.append(self._T, t)
211-
QT_new = np.empty(self._QT.shape[0] + 1)
211+
QT_new = np.empty(self._QT.shape[0] + 1, dtype=np.float64)
212212
S = T_new[l:]
213213
t_drop = T_new[l - 1]
214214

stumpy/core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def _calculate_squared_distance_profile(m, QT, μ_Q, σ_Q, M_T, Σ_T):
927927
See Equation on Page 4
928928
"""
929929
k = M_T.shape[0]
930-
D_squared = np.empty(k)
930+
D_squared = np.empty(k, dtype=np.float64)
931931

932932
for i in prange(k):
933933
D_squared[i] = _calculate_squared_distance(m, QT[i], μ_Q, σ_Q, M_T[i], Σ_T[i])
@@ -1069,7 +1069,7 @@ def mass_absolute(Q, T, T_subseq_isfinite=None, T_squared=None):
10691069
f"the length of `T` ({len(T)}). "
10701070
)
10711071

1072-
distance_profile = np.empty(n - m + 1)
1072+
distance_profile = np.empty(n - m + 1, dtype=np.float64)
10731073
if np.any(~np.isfinite(Q)):
10741074
distance_profile[:] = np.inf
10751075
else:
@@ -1159,11 +1159,11 @@ def mueen_calculate_distance_profile(Q, T):
11591159
Q_norm = (Q - μ_Q) / σ_Q
11601160
QT = sliding_dot_product(Q_norm, T)
11611161

1162-
cumsum_T = np.empty(len(T) + 1) # Add one element, fix off-by-one
1162+
cumsum_T = np.empty(len(T) + 1, dtype=np.float64) # Add one element, fix off-by-one
11631163
np.cumsum(T, out=cumsum_T[1:]) # store output in cumsum_T[1:]
11641164
cumsum_T[0] = 0
11651165

1166-
cumsum_T_squared = np.empty(len(T) + 1)
1166+
cumsum_T_squared = np.empty(len(T) + 1, dtype=np.float64)
11671167
np.cumsum(np.square(T), out=cumsum_T_squared[1:])
11681168
cumsum_T_squared[0] = 0
11691169

@@ -1320,7 +1320,7 @@ def mass(Q, T, M_T=None, Σ_T=None, normalize=True):
13201320
f"the length of `T` ({len(T)}). "
13211321
)
13221322

1323-
distance_profile = np.empty(n - m + 1)
1323+
distance_profile = np.empty(n - m + 1, dtype=np.float64)
13241324
if np.any(~np.isfinite(Q)):
13251325
distance_profile[:] = np.inf
13261326
else:
@@ -1668,7 +1668,7 @@ def _get_array_ranges(a, n_chunks, truncate):
16681668
pair. The first column contains the start indices and the second column
16691669
contains the stop indices.
16701670
"""
1671-
array_ranges = np.zeros((n_chunks, 2), np.int64)
1671+
array_ranges = np.zeros((n_chunks, 2), dtype=np.int64)
16721672
if a.shape[0] > 0 and n_chunks > 0:
16731673
cumsum = a.cumsum() / a.sum()
16741674
insert = np.linspace(0, 1, n_chunks + 1)[1:-1]

stumpy/floss.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _nnmark(I):
3939
I[idx] = idx
4040

4141
k = I.shape[0]
42-
i = np.arange(k)
42+
i = np.arange(k, dtype=np.int64)
4343

4444
nnmark = np.bincount(np.minimum(i, I), minlength=k)
4545
nnmark -= np.bincount(np.maximum(i, I), minlength=k)
@@ -86,15 +86,15 @@ def _iac(
8686
"""
8787
np.random.seed(seed)
8888

89-
I = np.random.randint(0, width, size=width)
89+
I = np.random.randint(0, width, size=width, dtype=np.int64)
9090
if bidirectional is False: # Idealized 1-dimensional matrix profile index
9191
I[:-1] = width
9292
for i in range(width - 1):
93-
I[i] = np.random.randint(i + 1, width)
93+
I[i] = np.random.randint(i + 1, width, dtype=np.int64)
9494

9595
target_AC = _nnmark(I)
9696

97-
params = np.empty((n_iter, 2))
97+
params = np.empty((n_iter, 2), dtype=np.float64)
9898
for i in range(n_iter):
9999
hist_dist = scipy.stats.rv_histogram(
100100
(target_AC, np.append(np.arange(width), width))
@@ -164,7 +164,7 @@ def _cac(I, L, bidirectional=True, excl_factor=5, custom_iac=None, seed=0):
164164
"""
165165
k = I.shape[0]
166166
AC = _nnmark(I)
167-
CAC = np.zeros(k)
167+
CAC = np.zeros(k, dtype=np.float64)
168168

169169
if custom_iac is None:
170170
IAC = _iac(k, bidirectional, seed=seed)
@@ -218,7 +218,7 @@ def _rea(cac, n_regimes, L, excl_factor=5):
218218
219219
This is the implementation for the regime extracting algorithm (REA).
220220
"""
221-
regime_locs = np.empty(n_regimes - 1, dtype=np.int)
221+
regime_locs = np.empty(n_regimes - 1, dtype=np.int64)
222222
tmp_cac = copy.deepcopy(cac)
223223
for i in range(n_regimes - 1):
224224
regime_locs[i] = np.argmin(tmp_cac)
@@ -483,7 +483,7 @@ def __init__(
483483
n_samples=self._n_samples,
484484
)
485485

486-
right_nn = np.zeros((self._k, self._m))
486+
right_nn = np.zeros((self._k, self._m), dtype=np.float64)
487487

488488
# Disable the bidirectional matrix profile indices and left indices
489489
self._mp[:, 1] = -1
@@ -492,7 +492,10 @@ def __init__(
492492
# Update matrix profile distance to be right mp distance and not bidirectional.
493493
# Use right indices to perform direct distance calculations
494494
# Note that any -1 indices must have a np.inf matrix profile value
495-
right_indices = [np.arange(IR, IR + self._m) for IR in self._mp[:, 3].tolist()]
495+
right_indices = [
496+
np.arange(IR, IR + self._m, dtype=np.int64)
497+
for IR in self._mp[:, 3].tolist()
498+
]
496499
right_nn[:] = self._T[np.array(right_indices)]
497500
if self._normalize:
498501
self._mp[:, 0] = np.linalg.norm(
@@ -509,7 +512,7 @@ def __init__(
509512
self._mp[inf_indices, 0] = np.inf
510513
self._mp[inf_indices, 3] = inf_indices
511514

512-
self._cac = np.ones(self._k) * -1
515+
self._cac = np.ones(self._k, dtype=np.float64) * -1
513516

514517
def update(self, t):
515518
"""

stumpy/gpu_aamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ def _gpu_aamp(
300300
device_T_B_subseq_isfinite = cuda.to_device(T_B_subseq_isfinite)
301301
device_T_B_subseq_squared = cuda.to_device(T_B_subseq_squared)
302302

303-
profile = np.full((k, 3), np.inf) # float64
304-
indices = np.full((k, 3), -1, dtype=np.int64) # int64
303+
profile = np.full((k, 3), np.inf, dtype=np.float64)
304+
indices = np.full((k, 3), -1, dtype=np.int64)
305305

306306
device_profile = cuda.to_device(profile)
307307
device_indices = cuda.to_device(indices)

stumpy/gpu_stump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ def _gpu_stump(
316316
device_M_T = cuda.to_device(M_T)
317317
device_Σ_T = cuda.to_device(Σ_T)
318318

319-
profile = np.full((k, 3), np.inf) # float64
320-
indices = np.full((k, 3), -1, dtype=np.int64) # int64
319+
profile = np.full((k, 3), np.inf, dtype=np.float64)
320+
indices = np.full((k, 3), -1, dtype=np.int64)
321321

322322
device_profile = cuda.to_device(profile)
323323
device_indices = cuda.to_device(indices)

0 commit comments

Comments
 (0)