@verbose
def _get_partitions_from_connectivity(connectivity, n_times, verbose=None):
 if isinstance(connectivity, list):
  test = np.ones(len(connectivity))
  test_conn = np.zeros((len(connectivity), len(connectivity)), dtype='bool')
  for vi in range(len(connectivity)):
   test_conn[(connectivity[vi], vi)] = True
  test_conn = sparse.coo_matrix(test_conn, dtype='float')
 else:
  test = np.ones(connectivity.shape[0])
  test_conn = connectivity
 part_clusts = _find_clusters(test, 0, 1, test_conn)[0]
 if (len(part_clusts) > 1):
  logger.info(('%i disjoint connectivity sets found' % len(part_clusts)))
  partitions = np.zeros(len(test), dtype='int')
  for (ii, pc) in enumerate(part_clusts):
   partitions[pc] = ii
  if isinstance(connectivity, list):
   partitions = np.tile(partitions, n_times)
 else:
  logger.info('No disjoint connectivity sets found')
  partitions = None
 return partitions

@ verbose def _get_partitions_from_connectivity ( connectivity , n_times , verbose = None ) : if isinstance ( connectivity , list ) : test = np . ones ( len ( connectivity ) ) test_conn = np . zeros ( ( len ( connectivity ) , len ( connectivity ) ) , dtype = 'bool' ) for vi in range ( len ( connectivity ) ) : test_conn [ ( connectivity [ vi ] , vi ) ] = True test_conn = sparse . coo_matrix ( test_conn , dtype = 'float' ) else : test = np . ones ( connectivity . shape [ 0 ] ) test_conn = connectivity part_clusts = _find_clusters ( test , 0 , 1 , test_conn ) [ 0 ] if ( len ( part_clusts ) > 1 ) : logger . info ( ( '%i disjoint connectivity sets found' % len ( part_clusts ) ) ) partitions = np . zeros ( len ( test ) , dtype = 'int' ) for ( ii , pc ) in enumerate ( part_clusts ) : partitions [ pc ] = ii if isinstance ( connectivity , list ) : partitions = np . tile ( partitions , n_times ) else : logger . info ( 'No disjoint connectivity sets found' ) partitions = None return partitions
specify disjoint subsets based on connectivity .