MCPcopy
hub / github.com/thampiman/reverse-geocoder / _pquery

Function _pquery

reverse_geocoder/cKDTree_MP.py:17–36  ·  view source on GitHub ↗

Function that parallelly queries the K-D tree based on chunks of data returned by the scheduler

(scheduler, data, ndata, ndim, leafsize,
            x, nx, d, i, k, eps, p, dub, ierr)

Source from the content-addressed store, hash-verified

15 return np.frombuffer(shmem_array.get_obj())
16
17def _pquery(scheduler, data, ndata, ndim, leafsize,
18 x, nx, d, i, k, eps, p, dub, ierr):
19 """
20 Function that parallelly queries the K-D tree based on chunks of data returned by the scheduler
21 """
22 try:
23 _data = shmem_as_nparray(data).reshape((ndata, ndim))
24 _x = shmem_as_nparray(x).reshape((nx, ndim))
25 _d = shmem_as_nparray(d).reshape((nx, k))
26 _i = shmem_as_nparray(i).reshape((nx, k))
27
28 kdtree = cKDTree(_data, leafsize=leafsize)
29
30 for s in scheduler:
31 d_out, i_out = kdtree.query(_x[s, :], k=k, eps=eps, p=p, distance_upper_bound=dub)
32 m_d = d_out.shape[0]
33 m_i = i_out.shape[0]
34 _d[s, :], _i[s, :] = d_out.reshape(m_d, 1), i_out.reshape(m_i, 1)
35 except:
36 ierr.value += 1
37
38def num_cpus():
39 """

Callers

nothing calls this directly

Calls 2

shmem_as_nparrayFunction · 0.85
queryMethod · 0.80

Tested by

no test coverage detected