def order_angles_golden_ratio(theta):
 interval = 180
 def angle_distance(a, b):
  difference = (a - b)
  return min(abs((difference % interval)), abs((difference % (- interval))))
 remaining = list(np.argsort(theta))
 index = remaining.pop(0)
 angle = theta[index]
 (yield index)
 angle_increment = (interval * (1 - ((np.sqrt(5) - 1) / 2)))
 while remaining:
  angle = ((angle + angle_increment) % interval)
  insert_point = np.searchsorted(theta[remaining], angle)
  index_below = (insert_point - 1)
  index_above = (0 if (insert_point == len(remaining)) else insert_point)
  distance_below = angle_distance(angle, theta[remaining[index_below]])
  distance_above = angle_distance(angle, theta[remaining[index_above]])
  if (distance_below < distance_above):
   (yield remaining.pop(index_below))
  else:
   (yield remaining.pop(index_above))

def order_angles_golden_ratio ( theta ) : interval = 180 def angle_distance ( a , b ) : difference = ( a - b ) return min ( abs ( ( difference % interval ) ) , abs ( ( difference % ( - interval ) ) ) ) remaining = list ( np . argsort ( theta ) ) index = remaining . pop ( 0 ) angle = theta [ index ] ( yield index ) angle_increment = ( interval * ( 1 - ( ( np . sqrt ( 5 ) - 1 ) / 2 ) ) ) while remaining : angle = ( ( angle + angle_increment ) % interval ) insert_point = np . searchsorted ( theta [ remaining ] , angle ) index_below = ( insert_point - 1 ) index_above = ( 0 if ( insert_point == len ( remaining ) ) else insert_point ) distance_below = angle_distance ( angle , theta [ remaining [ index_below ] ] ) distance_above = angle_distance ( angle , theta [ remaining [ index_above ] ] ) if ( distance_below < distance_above ) : ( yield remaining . pop ( index_below ) ) else : ( yield remaining . pop ( index_above ) )
order angles to reduce the amount of correlated information in subsequent projections .