diff --git a/sparse/_compressed/indexing.py b/sparse/_compressed/indexing.py index b0696fc3..c78a03b0 100644 --- a/sparse/_compressed/indexing.py +++ b/sparse/_compressed/indexing.py @@ -231,7 +231,7 @@ def get_slicing_selection(arr_data, arr_indices, indptr, starts, ends, col): # col_count += 1 ind_list.extend(inds) indptr[i + 1] = indptr[i] + len(inds) - ind_list = np.array(ind_list, dtype=np.int64) + ind_list = np.array(ind_list, dtype=np.intp) indices = np.array(indices, dtype=indptr.dtype) data = arr_data[ind_list] return (data, indices, indptr) @@ -260,7 +260,7 @@ def get_array_selection(arr_data, arr_indices, indptr, starts, ends, col): # pr indices.append(c) ind_list.extend(inds) indptr[i + 1] = indptr[i] + len(inds) - ind_list = np.array(ind_list, dtype=np.int64) + ind_list = np.array(ind_list, dtype=np.intp) indices = np.array(indices, dtype=indptr.dtype) data = arr_data[ind_list] return (data, indices, indptr) diff --git a/sparse/_umath.py b/sparse/_umath.py index 25715f1b..1fbf191b 100644 --- a/sparse/_umath.py +++ b/sparse/_umath.py @@ -1,4 +1,6 @@ import itertools +import operator +from functools import reduce from itertools import zip_longest import numba @@ -256,7 +258,7 @@ def _get_expanded_coords_data(coords, data, params, broadcast_shape): expanded_data = data[all_idx[first_dim]] else: expanded_coords = all_idx if len(data) else np.empty((0, all_idx.shape[1]), dtype=np.intp) - expanded_data = np.repeat(data, np.prod(broadcast_shape, dtype=np.int64)) + expanded_data = np.repeat(data, reduce(operator.mul, broadcast_shape, 1)) return np.asarray(expanded_coords), np.asarray(expanded_data) for d, p in zip(range(len(broadcast_shape)), params): diff --git a/sparse/_utils.py b/sparse/_utils.py index 8a612c4d..28f339bf 100644 --- a/sparse/_utils.py +++ b/sparse/_utils.py @@ -110,19 +110,19 @@ def algD(n, N, random_state): N = size of system (elements) random_state = seed for random number generation """ - n = np.int64(n + 1) - N = np.int64(N) + n = np.intp(n + 1) + N = np.intp(N) qu1 = N - n + 1 Vprime = np.exp(np.log(random_state.random()) / n) i = 0 - arr = np.zeros(n - 1, dtype=np.int64) + arr = np.zeros(n - 1, dtype=np.intp) arr[-1] = -1 while n > 1: nmin1inv = 1 / (n - 1) while True: while True: X = N * (1 - Vprime) - S = np.int64(X) + S = np.intp(X) if qu1 > S: break Vprime = np.exp(np.log(random_state.random()) / n) @@ -167,9 +167,9 @@ def algA(n, N, random_state): N = size of system (elements) random_state = seed for random number generation """ - n = np.int64(n) - N = np.int64(N) - arr = np.zeros(n, dtype=np.int64) + n = np.intp(n) + N = np.intp(N) + arr = np.zeros(n, dtype=np.intp) arr[-1] = -1 i = 0 top = N - n @@ -186,7 +186,7 @@ def algA(n, N, random_state): i += 1 N -= 1 n -= 1 - S = np.int64(N * random_state.random()) + S = np.intp(N * random_state.random()) arr[i] = arr[i - 1] + S + 1 i += 1 return arr @@ -197,11 +197,11 @@ def reverse(inv, N): """ If density of random matrix is greater than .5, it is faster to sample states not included Parameters: - arr = np.array(np.int64) of indices to be excluded from sample + arr = np.array(np.intp) of indices to be excluded from sample N = size of the system (elements) """ - N = np.int64(N) - a = np.zeros(np.int64(N - len(inv)), dtype=np.int64) + N = np.intp(N) + a = np.zeros(np.intp(N - len(inv)), dtype=np.intp) j = 0 k = 0 for i in range(N):