parameters: (self, tolerance)
return_statement: return close_node_groups
docstring: Return groups of nodes that are close to one another.
  
          This will search for all nodes which are separated by at most
          'tolerance' and return a list of node groups.
  
          If node A is close to node B, and node B is close to node C, then each
          A, B, and C will belong to the same node group, regardless of whether
          or not node A is close to node C.
  
          Results are returned as a dict of node groups with the lowest index
          node being the key and the value as the list of slave nodes.  For
          example, if nodes 0 and 1 are close, and 2 and 3 are close, it would
          return:
          >>> model._find_close_nodes()
          {0: [1], 2: [3]}
docstring_summary: Return groups of nodes that are close to one another.
docstring_tokens: Return groups of nodes that are close to one another .
function: def _find_close_nodes(self, tolerance):
          """
          Return groups of nodes that are close to one another.
  
          This will search for all nodes which are separated by at most
          'tolerance' and return a list of node groups.
  
          If node A is close to node B, and node B is close to node C, then each
          A, B, and C will belong to the same node group, regardless of whether
          or not node A is close to node C.
  
          Results are returned as a dict of node groups with the lowest index
          node being the key and the value as the list of slave nodes.  For
          example, if nodes 0 and 1 are close, and 2 and 3 are close, it would
          return:
          >>> model._find_close_nodes()
          {0: [1], 2: [3]}
  
          """
          # create a sorting vector
          sorting_vector = [math.pi, 2.0, 0.5 * math.sqrt(2)]
          scale = math.sqrt(sum([x * x for x in sorting_vector]))
          sorting_vector = [x / scale for x in sorting_vector]
          # create a list of node indices sorted by distance along that vector
          sorted_nodal_distances = sorted([(self._dot(x, sorting_vector), i)
                                           for i, x in enumerate(self.nodes)])
          # go through the list to find node groups
          node_count = len(self.nodes)
          lower_index = 0
          upper_index = 1
          master_nodes = list(range(len(self.nodes)))
          while lower_index < node_count:
              if (upper_index >= node_count
                      or sorted_nodal_distances[upper_index][0] -
                      sorted_nodal_distances[lower_index][0] > tolerance):
                  lower_index += 1
                  upper_index = lower_index + 1
                  continue
              lower_element = sorted_nodal_distances[lower_index]
              upper_element = sorted_nodal_distances[upper_index]
              if self._distance_between(
                      self.nodes[lower_element[1]],
                      self.nodes[upper_element[1]]) <= tolerance:
                  one, two = sorted([lower_element[1], upper_element[1]])
                  master_nodes[two] = one
              upper_index += 1
          # create a list of close node groups
          close_node_groups = dict()
          for index, master_node in enumerate(master_nodes):
              if index != master_node:
                  while master_nodes[master_node] != master_node:
                      assert master_nodes[master_node] < master_node
                      master_node = master_nodes[master_node]
                  if master_node not in close_node_groups:
                      close_node_groups[master_node] = []
                  close_node_groups[master_node].append(index)
          # return the result
          return close_node_groups
function_tokens: def _find_close_nodes ( self , tolerance ) : # create a sorting vector sorting_vector = [ math . pi , 2.0 , 0.5 * math . sqrt ( 2 ) ] scale = math . sqrt ( sum ( [ x * x for x in sorting_vector ] ) ) sorting_vector = [ x / scale for x in sorting_vector ] # create a list of node indices sorted by distance along that vector sorted_nodal_distances = sorted ( [ ( self . _dot ( x , sorting_vector ) , i ) for i , x in enumerate ( self . nodes ) ] ) # go through the list to find node groups node_count = len ( self . nodes ) lower_index = 0 upper_index = 1 master_nodes = list ( range ( len ( self . nodes ) ) ) while lower_index < node_count : if ( upper_index >= node_count or sorted_nodal_distances [ upper_index ] [ 0 ] - sorted_nodal_distances [ lower_index ] [ 0 ] > tolerance ) : lower_index += 1 upper_index = lower_index + 1 continue lower_element = sorted_nodal_distances [ lower_index ] upper_element = sorted_nodal_distances [ upper_index ] if self . _distance_between ( self . nodes [ lower_element [ 1 ] ] , self . nodes [ upper_element [ 1 ] ] ) <= tolerance : one , two = sorted ( [ lower_element [ 1 ] , upper_element [ 1 ] ] ) master_nodes [ two ] = one upper_index += 1 # create a list of close node groups close_node_groups = dict ( ) for index , master_node in enumerate ( master_nodes ) : if index != master_node : while master_nodes [ master_node ] != master_node : assert master_nodes [ master_node ] < master_node master_node = master_nodes [ master_node ] if master_node not in close_node_groups : close_node_groups [ master_node ] = [ ] close_node_groups [ master_node ] . append ( index ) # return the result return close_node_groups