@@ -580,9 +580,9 @@ def gen_spinsamples(coords, hemiid, n_rotate=1000, check_duplicates=True,
580580 >>> nnstats.gen_spinsamples(coords, hemi, n_rotate=1, seed=1,
581581 ... method='original', check_duplicates=False)
582582 array([[0],
583- [1 ],
583+ [0 ],
584584 [2],
585- [2 ]], dtype=int32)
585+ [3 ]], dtype=int32)
586586
587587 While this is reasonable in most circumstances, if you feel incredibly
588588 strongly about having a perfect "permutation" (i.e., all indices appear
@@ -675,12 +675,6 @@ def gen_spinsamples(coords, hemiid, n_rotate=1000, check_duplicates=True,
675675 cost = np .zeros ((len (coords ), n_rotate ))
676676 inds = np .arange (len (coords ), dtype = 'int32' )
677677
678- # precompute kd trees
679- kdtrees = (
680- spatial .cKDTree (coords [hemiid == 0 ]),
681- spatial .cKDTree (coords [hemiid == 1 ])
682- )
683-
684678 # generate rotations and resampling array!
685679 msg , warned = '' , False
686680 for n in range (n_rotate ):
@@ -731,7 +725,7 @@ def gen_spinsamples(coords, hemiid, n_rotate=1000, check_duplicates=True,
731725 # huge thanks to https://stackoverflow.com/a/47779290 for this
732726 # memory-efficient method
733727 elif method == 'original' :
734- dist , col = kdtrees [ h ]. query (coor @ rot , 1 )
728+ dist , col = spatial . cKDTree (coor @ rot ). query ( coor , 1 )
735729 cost [hinds , n ] = dist
736730
737731 resampled [hinds ] = inds [hinds ][col ]
0 commit comments