Skip to content

Commit 367f1f6

Browse files
committed
ExpertSolver: fix crash in prep_interpolate() and expert_interpolate_continuous() in the 1D case
1 parent 2e8bba2 commit 367f1f6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

wlsqm/fitter/expert.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,9 @@ after calling solve().
668668
if self.host is not None: # in guest mode, use the host's tree for searching
669669
self.tree = self.host.tree
670670
else:
671-
self.tree = scipy.spatial.cKDTree( data=self.xi )
671+
# KDTree input format: rank-2 array of (N,K), where N = number of points, K = number of dimensions
672+
xi_rank2 = self.xi if self.dimension >= 2 else np.atleast_2d(self.xi).T
673+
self.tree = scipy.spatial.cKDTree( data=xi_rank2 )
672674

673675

674676
# TODO: continuous mode: add options for falloff, weighting function shape
@@ -882,7 +884,8 @@ cdef void expert_interpolate_nearest( int dimension, xi_tree, infra.CaseManager*
882884
cdef void expert_interpolate_continuous( int dimension, xi, xi_tree, infra.CaseManager* manager, x, double[::1] out, int diff, r ): # TODO/FIXME: always single-threaded for now
883885
# Index the points where the global model is to be interpolated (for faster searching of pairs).
884886
# TODO: add caching to ExpertSolver if this is the same as the last used x ("if x is x_cached"?) OTOH, this would keep alive a reference to a caller-given array (that is probably intended as a temporary)...
885-
input_tree = scipy.spatial.cKDTree( data=x )
887+
x_rank2 = x if dimension >= 2 else np.atleast_2d(x).T
888+
input_tree = scipy.spatial.cKDTree( data=x_rank2 )
886889

887890
# For each point in x, find all local models whose origin is within radius r.
888891
#

0 commit comments

Comments
 (0)