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)
| 15 | return np.frombuffer(shmem_array.get_obj()) |
| 16 | |
| 17 | def _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 | |
| 38 | def num_cpus(): |
| 39 | """ |
nothing calls this directly
no test coverage detected