Commit 2b5e6a04 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

BUG: don't uncompress and recompress orientations

parent 0deac625
Pipeline #5291 failed with stage
in 8 minutes and 3 seconds
......@@ -137,7 +137,7 @@ class RadialBasis(BasisFunc):
"""Dimensionality of the space in which the RBF is embedded"""
return self.centroids.shape[-1]
def within_range(self, req):
def within_range(self, req, return_compressed=False):
"""
Return for every centroid which elements of the request are within range.
......@@ -145,6 +145,7 @@ class RadialBasis(BasisFunc):
:param req: describes where the basis function should be evaluated
:type req: request.FieldRequest
:param return_compressed: return the request indices in a compressed format
:return: tuple with the request and centroid indices in compressed format
"""
if self._precomputed_grids is not None:
......@@ -164,8 +165,10 @@ class RadialBasis(BasisFunc):
max_size = size1.max() + req.radius().max()
list_of_lists = tree2.query_ball_tree(self.tree, r=max_size)
idx_req_compressed = sp.append(0, sp.cumsum([len(l) for l in list_of_lists]))
idx_req = sp.digitize(sp.arange(idx_req_compressed[-1]), idx_req_compressed[1:])
idx_centroid = sp.fromiter(itertools.chain(*list_of_lists), dtype='i4')
if return_compressed:
return idx_req_compressed, idx_centroid
idx_req = sp.digitize(sp.arange(idx_req_compressed[-1]), idx_req_compressed[1:])
return idx_req, idx_centroid
def bounding_box(self, extent=0):
......@@ -607,9 +610,12 @@ __global__ void matrix_mult_nd_invert({dtype} *derparam, {dtype} *derfield, int
def update_indices(self, only_forward=False):
del self.forward_idx
del self.backward_idx
idx_req, idx_centroids = self.basis.within_range(self.request)
forward_compressed = sp.append(0, sp.cumsum(sp.bincount(idx_req, minlength=self.request.npos)))
forward_idx = idx_centroids# [sp.argsort(idx_req)]; idx_req is always sorted
if only_forward:
forward_compressed, forward_idx = self.basis.within_range(self.request, return_compressed=True)
else:
idx_req, idx_centroids = self.basis.within_range(self.request)
forward_compressed = sp.append(0, sp.cumsum(sp.bincount(idx_req, minlength=self.request.npos)))
forward_idx = idx_centroids # [sp.argsort(idx_req)]; idx_req is always sorted
self.forward_idx = (cuda.to_gpu_correct(forward_compressed),
cuda.to_gpu_correct(forward_idx))
if only_forward:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment