Skip to content

Commit bc046c8

Browse files
committed
Change dtype for splice from uint64 to int64
Adding/substracting uint64 and int64 gives back a float, which is a problem if you want to use the result to index another array. See numpy/numpy#7126
1 parent 6790fdc commit bc046c8

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎core.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ def fwhm(x):
19101910
Finds the FWHM of the global maximum of x[i], for all i.
19111911
"""
19121912
n = x.shape[0]
1913-
fwhm = np.zeros(n, dtype=np.uint64)
1913+
fwhm = np.zeros(n, dtype=np.int64)
19141914
for i in prange(n):
19151915
imax = np.argmax(x[i])
19161916
ind = np.asarray(x[i] < x[i][imax]/2).nonzero()[0]
@@ -2030,7 +2030,7 @@ def whiten(T, splice, coeffs, grp_delay):
20302030
----------
20312031
T: numpy.ndarray(dtype=float64)
20322032
Time series. T.shape=(l,).
2033-
splice: numpy.ndarray(dtype=uint64)
2033+
splice: numpy.ndarray(dtype=int64)
20342034
splice[i] has the start index of the (i+1)th-segment (e.g., 2nd segment
20352035
starts at splice[0], 3rd segment at splice[1], and so on), for i=0,..,
20362036
n, and n+1 being the number of segments that were concatenated to form
@@ -2044,23 +2044,23 @@ def whiten(T, splice, coeffs, grp_delay):
20442044
-------
20452045
filt_T: numpy.ndarray(dtype=float64)
20462046
Filtered time series. If splice is not empty, filter each segment, discard first `grp_delay` samples, and concatenate back.
2047-
new_splice: numpy.ndarray(dtype=uint64)
2047+
new_splice: numpy.ndarray(dtype=int64)
20482048
Update splice indices, after discarding the first `grp_delay` samples
20492049
on each filtered segment.
20502050
"""
20512051

20522052
n_seg = splice.size + 1
20532053
end_seg = np.r_[splice, T.size] # end index of each segment
2054-
end_seg = end_seg.astype(np.uint64)
2054+
end_seg = end_seg
20552055

20562056
filt_T = np.zeros(T.size-n_seg*grp_delay)
20572057

20582058
start = 0
20592059
dstart = 0
2060-
new_splice = np.zeros(splice.shape, dtype=np.uint64)
2060+
new_splice = np.zeros(splice.shape, dtype=np.int64)
20612061
for i, end in enumerate(end_seg):
20622062
x = lfilter(coeffs, 1, T[start:end], axis=0)
2063-
dend = int(end - (i+1)*grp_delay)
2063+
dend = end - (i+1)*grp_delay
20642064
filt_T[dstart:dend] = x[grp_delay:]
20652065
start = end
20662066
dstart = dend

‎utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def cat_segments(dpath, W, train_len=None):
126126
cumlen = np.cumsum(seglen)
127127
splice = cumlen[:-1] # start index for second to last segment
128128

129-
return ts, splice.astype(np.uint64)
129+
return ts, splice
130130

131131
def fix_root(qsmp):
132132
profile, neighbor, density = qsmp
@@ -158,7 +158,7 @@ def get_waves(modes, ts, m, max_modes=None):
158158

159159
def fwhm(x):
160160
n = x.shape[0]
161-
fwhm = np.zeros(n, dtype=np.uint64)
161+
fwhm = np.zeros(n, dtype=np.int64)
162162
for i in range(n):
163163
imax = np.argmax(x[i])
164164
ind = np.asarray(x[i] < x[i][imax]/2).nonzero()[0]

0 commit comments

Comments
 (0)