I'm struggling to find a quick way to convert a list of lists to an array of pairs. The first value of the pair is the index of the list row and the second value is made up of each value in the list for that list row. If the row is an empty list then no pair exists and should not be created.
I'm looking to get something similar to the result obtained via :
combarray = numpy.concatenate((t1, t2), axis=0)
tree = cKDTree(combarray)
pairlist = tree.query_pairs(r = distance )
pairs = numpy.array(list(pairlist))
points = len(t1)
check = numpy.logical_and(pairs[:,0] < points, pairs[:,1] >= points)
validpairs = pairs[check]
validpairs[:,1] -= points
unfortunately the combining of the two arrays of points causes the main tree.query_pairs call to take approx twice as long as using t1tree.query_ball_tree(t2tree,r = distance) due to size of the combined two arrays. If I can convert the result from the KDTree.query ball back to a pair array efficiently then it may be the faster option to use.
t1 is a set of vertex points in 3d and t2 is a different set of vertex points in 3d. distance is a parameter to establish 'near' points some of which will have the same vertex value i.e. I am using a value currently of 0.02. tha main point here though is to convert the list of lists eg
row 0 : []
row 1 : [ 3, 5]
row 2 : [ 1 ]
row 3 : []
row 4 : [ 2 ]
to an array of pairs : [[1,3], [1,5], [2,1], [4,2]]
Most rows will be empty and generally there is only likely to be a few (elements in each row i.e. probably up to 20 but its an unknown). Each set of t1 and t2 values may be from 3 to around 3000 values.