The outputs of the partition at ``partition_index``.

        Note that this returns a tuple of element indices, since coarse-
        grained blackboxes may have multiple outputs.
976348
def outputs_of(self, partition_index):
        
        partition = self.partition[partition_index]
        outputs = set(partition).intersection(self.output_indices)
        return tuple(sorted(outputs))
446852
def read_partition(self, i):
        
        self._load_metadata()
        if i < 0 or i >= self.npartitions:
            raise IndexError('%d is out of range' % i)

        return self._get_partition(i)
383213
def _partition_species(composition, max_components=2):
        

        def _partition(collection):
            # thanks https://stackoverflow.com/a/30134039

            if len(collection) == 1:
                yield [collection]
                return

            first = collection[0]
            for smaller in _partition(collection[1:]):
                # insert `first` in each of the subpartition's subsets
                for n, subset in enumerate(smaller):
                    yield smaller[:n] + [[first] + subset] + smaller[n + 1:]
                # put `first` in its own subset
                yield [[first]] + smaller

        def _sort_partitions(partitions_to_sort):
            """
            Sort partitions by those we want to check first
            (typically, merging two sites into one is the
            one to try first).
            """

            partition_indices = [(idx, [len(p) for p in partition])
                                 for idx, partition in enumerate(partitions_to_sort)]

            # sort by maximum length of partition first (try smallest maximums first)
            # and secondarily by number of partitions (most partitions first, i.e.
            # create the 'least disordered' structures first)
            partition_indices = sorted(partition_indices, key=lambda x: (max(x[1]), -len(x[1])))

            # merge at most max_component sites,
            # e.g. merge at most 2 species into 1 disordered site
            partition_indices = [x for x in partition_indices if max(x[1]) <= max_components]

            partition_indices.pop(0)  # this is just the input structure

            sorted_partitions = [partitions_to_sort[x[0]] for x in partition_indices]

            return sorted_partitions

        collection = list(composition.keys())
        partitions = list(_partition(collection))
        partitions = _sort_partitions(partitions)

        return partitions
1010884
def poll_output(self):
        
        if self.block:
            return self.output

        new_list = self.output[self.old_output_size:]
        self.old_output_size += len(new_list)
        return new_list
844664
def _xfs_estimate_output(out):
    '''
    
    '''
    spc = re.compile(r"\s+")
    data = {}
    for line in [l for l in out.split("\n") if l.strip()][1:]:
        directory, bsize, blocks, megabytes, logsize = spc.sub(" ", line).split(" ")
        data[directory] = {
            'block _size': bsize,
            'blocks': blocks,
            'megabytes': megabytes,
            'logsize': logsize,
        }

    return data
351342
def getSparseWeights(weightSparsity, inputSize, outputSize):
  
  # Initialize weights in the typical fashion.
  w = torch.Tensor(outputSize, inputSize)
  stdv = 1. / math.sqrt(w.size(1))
  w.data.uniform_(-stdv, stdv)

  numZeros = int(round((1.0 - weightSparsity) * inputSize))

  outputIndices = np.arange(outputSize)
  inputIndices = np.array([np.random.permutation(inputSize)[:numZeros]
                           for _ in outputIndices], dtype=np.long)

  # Create tensor indices for all non-zero weights
  zeroIndices = np.empty((outputSize, numZeros, 2), dtype=np.long)
  zeroIndices[:, :, 0] = outputIndices[:, None]
  zeroIndices[:, :, 1] = inputIndices
  zeroIndices = torch.LongTensor(zeroIndices.reshape(-1, 2))

  zeroWts = (zeroIndices[:, 0], zeroIndices[:, 1])
  w.data[zeroWts] = 0.0

  return w
30625
def partitions(self):
        
        # We do here some lazy loading.
        if not self._partitions:
            self._partitions = PartitionManager(self)
        return self._partitions
214050
def calculate_sparkml_string_indexer_output_shapes(operator):
    '''
    
    '''
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[Int64TensorType, StringTensorType])

    input_shape = copy.deepcopy(operator.inputs[0].type.shape)
    operator.outputs[0].type = Int64TensorType(input_shape)
312552
def _get_chunk_indices(za):
    # TODO: does zarr provide code for this?
    
    return [(i, j) for i in range(int(math.ceil(float(za.shape[0])/za.chunks[0])))
            for j in range(int(math.ceil(float(za.shape[1])/za.chunks[1])))]
815144
def _get_data(self) -> BaseFrameManager:
        

        def iloc(partition, row_internal_indices, col_internal_indices):
            return partition.iloc[row_internal_indices, col_internal_indices]

        masked_data = self.parent_data.apply_func_to_indices_both_axis(
            func=iloc,
            row_indices=self.index_map.values,
            col_indices=self.columns_map.values,
            lazy=False,
            keep_remaining=False,
        )
        return masked_data
1158545
def all_coarse_grains(indices):
    
    for partition in all_partitions(indices):
        for grouping in all_groupings(partition):
            yield CoarseGrain(partition, grouping)
784299
def hidden_indices(self):
        """"""
        return tuple(sorted(set(self.micro_indices) -
                            set(self.output_indices)))
1334976
def outputs_of(self, idx, create=False):
        
        if create and not idx in self.edges:
            self.edges[idx] = set()
        return self.edges[idx]
875397
def build_output_partitions(cls, name='inputTablePartitions', output_name='output'):
        
        obj = cls(name)
        obj.exporter = 'get_output_table_partition'
        obj.output_name = output_name
        return obj
416481
def output_clusters(labels, cluster_centers_indices):
    
            
    here = os.getcwd()
    try:
        output_directory = os.path.join(here, 'concurrent_AP_output')
        os.makedirs(output_directory)
    except OSError:
        if not os.path.isdir(output_directory):
            print("ERROR: concurrent_AP: output_clusters: cannot create a directory "
                  "for storage of the results of Affinity Propagation clustering "
                  "in your current working directory")
            sys.exit(1)
            
    if any(np.isnan(labels)):
        fmt = '%.1f'
    else:
        fmt = '%d'
                
    with open(os.path.join(output_directory, 'labels.tsv'), 'w') as fh:
        np.savetxt(fh, labels, fmt = fmt, delimiter = '\t')
        
    if cluster_centers_indices is not None:    
        with open(os.path.join(output_directory, 'cluster_centers_indices.tsv'), 'w') as fh:
            np.savetxt(fh, cluster_centers_indices, fmt = '%.1f', 
                       delimiter = '\t')
418043
def get_index(index_name, *partition_indices):  # pragma: no cover
    """"""
    index = partition_indices[0].append(partition_indices[1:])
    index.names = index_name
    return index
1135644
def blackbox(blackbox):
    """"""
    if tuple(sorted(blackbox.output_indices)) != blackbox.output_indices:
        raise ValueError('Output indices {} must be ordered'.format(
            blackbox.output_indices))

    partition(blackbox.partition)

    for part in blackbox.partition:
        if not set(part) & set(blackbox.output_indices):
            raise ValueError(
                'Every blackbox must have an output - {} does not'.format(
                    part))