def form_ntuples_from_machines(machines, n=2, mapping_func=default_mappings):
 ntuples = []
 (mappings, failures) = mapping_func(machines)
 for key in mappings:
  key_machines = mappings[key]
  total_machines = len(key_machines)
  while (len(key_machines) >= n):
   ntuples.append(key_machines[0:n])
   key_machines = key_machines[n:]
  for mach in key_machines:
   failures.append((mach, 'machine can not be tupled'))
 return (ntuples, failures)

def form_ntuples_from_machines ( machines , n = 2 , mapping_func = default_mappings ) : ntuples = [ ] ( mappings , failures ) = mapping_func ( machines ) for key in mappings : key_machines = mappings [ key ] total_machines = len ( key_machines ) while ( len ( key_machines ) >= n ) : ntuples . append ( key_machines [ 0 : n ] ) key_machines = key_machines [ n : ] for mach in key_machines : failures . append ( ( mach , 'machine can not be tupled' ) ) return ( ntuples , failures )
returns a set of ntuples from machines where the machines in an ntuple are in the same mapping .