def _add_patch_info(s):
 nearest = s['nearest']
 if (nearest is None):
  s['pinfo'] = None
  s['patch_inds'] = None
  return
 logger.info('    Computing patch statistics...')
 indn = np.argsort(nearest)
 nearest_sorted = nearest[indn]
 steps = (np.where((nearest_sorted[1:] != nearest_sorted[:(-1)]))[0] + 1)
 starti = np.r_[([0], steps)]
 stopi = np.r_[(steps, [len(nearest)])]
 pinfo = list()
 for (start, stop) in zip(starti, stopi):
  pinfo.append(np.sort(indn[start:stop]))
 s['pinfo'] = pinfo
 patch_verts = nearest_sorted[(steps - 1)]
 s['patch_inds'] = np.searchsorted(patch_verts, s['vertno'])
 logger.info('    Patch information added...')

def _add_patch_info ( s ) : nearest = s [ 'nearest' ] if ( nearest is None ) : s [ 'pinfo' ] = None s [ 'patch_inds' ] = None return logger . info ( '    Computing patch statistics...' ) indn = np . argsort ( nearest ) nearest_sorted = nearest [ indn ] steps = ( np . where ( ( nearest_sorted [ 1 : ] != nearest_sorted [ : ( - 1 ) ] ) ) [ 0 ] + 1 ) starti = np . r_ [ ( [ 0 ] , steps ) ] stopi = np . r_ [ ( steps , [ len ( nearest ) ] ) ] pinfo = list ( ) for ( start , stop ) in zip ( starti , stopi ) : pinfo . append ( np . sort ( indn [ start : stop ] ) ) s [ 'pinfo' ] = pinfo patch_verts = nearest_sorted [ ( steps - 1 ) ] s [ 'patch_inds' ] = np . searchsorted ( patch_verts , s [ 'vertno' ] ) logger . info ( '    Patch information added...' )
patch information in a source space .