Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@numba.njit()
def sparse_init_from_random(
n_neighbors,
inds,
indptr,
data,
query_inds,
query_indptr,
query_data,
heap,
rng_state,
sparse_dist,
dist_args,
):
for i in range(query_indptr.shape[0] - 1):
indices = rejection_sample(n_neighbors, indptr.shape[0] - 1, rng_state)
@numba.njit()
def sparse_diff(ind1, data1, ind2, data2):
return sparse_sum(ind1, data1, ind2, -data2)
@njit(dtype_2int_tuple(f8, f8), cache=True)
def coord2shortcut(lng, lat):
return int(floor((lng + 180))), int(floor((90 - lat) * 2))
@njit(f8(f8, f8, i4, i4[:, :]), cache=True)
def distance_to_polygon(lng_rad, lat_rad, nr_points, points):
min_distance = MAX_HAVERSINE_DISTANCE
for i in range(nr_points):
min_distance = min(min_distance, haversine(lng_rad, lat_rad, radians(int2coord(points[0][i])),
radians(int2coord(points[1][i]))))
return min_distance
@numba.njit()
def sparse_rogers_tanimoto(ind1, data1, ind2, data2, n_features):
num_true_true = arr_intersect(ind1, ind2).shape[0]
num_non_zero = arr_union(ind1, ind2).shape[0]
num_not_equal = num_non_zero - num_true_true
return (2.0 * num_not_equal) / (n_features + num_not_equal)
@njit()
def _reshape_list_shapelets(shapelets, lengths):
"""Reshape shapelets from a 1D-array to a list of 2D-arrays."""
shapelets_reshaped = []
start = 0
for length in lengths:
n_shapelets = length.size
length_ = length[0]
end = start + n_shapelets * length_
shapelets_reshaped.append(shapelets[start: end].reshape(-1, length_))
start = end
return shapelets_reshaped
@njit
def triplet_force_en_kernel(ci1, ci2, ri1, ri2, ri3, rj1, rj2, rj3,
fi, fj, fdi, ls1, ls2, sig2):
r11 = ri1-rj1
r12 = ri1-rj2
r13 = ri1-rj3
r21 = ri2-rj1
r22 = ri2-rj2
r23 = ri2-rj3
r31 = ri3-rj1
r32 = ri3-rj2
r33 = ri3-rj3
I1 = three_body_en_helper(ci1, ci2, r11, r22, r33, fi, fj,
fdi, ls1, ls2, sig2)
I2 = three_body_en_helper(ci1, ci2, r13, r21, r32, fi, fj,
fdi, ls1, ls2, sig2)
@njit
def triplet_kernel(ci1, ci2, cj1, cj2, ri1, ri2, ri3, rj1, rj2, rj3, fi, fj,
fdi, fdj, ls1, ls2, ls3, sig2):
r11 = ri1-rj1
r12 = ri1-rj2
r13 = ri1-rj3
r21 = ri2-rj1
r22 = ri2-rj2
r23 = ri2-rj3
r31 = ri3-rj1
r32 = ri3-rj2
r33 = ri3-rj3
# sum over all six permutations
M1 = three_body_helper_1(ci1, ci2, cj1, cj2, r11, r22, r33, fi, fj, fdi,
fdj, ls1, ls2, ls3, sig2)
M2 = three_body_helper_2(ci2, ci1, cj2, cj1, r21, r13, r32, fi, fj, fdi,
@njit
def __in_bounds__(position, board_size):
for p in position:
if not (p >= 0 and p < board_size):
return False
return True
@njit
def _iter(d):
return list(d.keys())