Prints out the ensemble composition at each size
187851
def write_ensemble(ensemble, options):
    

    # set output file name
    size = len(ensemble)
    filename = '%s_%s_queries.csv' % (options.outname, size)
    file = os.path.join(os.getcwd(), filename)

    f = open(file, 'w')

    out = ', '.join(ensemble)

    f.write(out)

    f.close()
139759
def compile_output(self, input_sample, num_samples, num_params,
                       maximum_combo, num_groups=None):
        

        if num_groups is None:
            num_groups = num_params

        self.check_input_sample(input_sample, num_groups, num_samples)

        index_list = self._make_index_list(num_samples, num_params, num_groups)

        output = np.zeros(
            (np.size(maximum_combo) * (num_groups + 1), num_params))
        for counter, combo in enumerate(maximum_combo):
            output[index_list[counter]] = np.array(
                input_sample[index_list[combo]])
        return output
1016908
def display(self):
        """"""
        #Finding the maximum length for each column
        sym_name = "Symbol name"
        sym_len = max(max(len(i.name) for i in self.table),len(sym_name))
        kind_name = "Kind"
        kind_len = max(max(len(SharedData.KINDS[i.kind]) for i in self.table),len(kind_name))
        type_name = "Type"
        type_len = max(max(len(SharedData.TYPES[i.type]) for i in self.table),len(type_name))
        attr_name = "Attribute"
        attr_len = max(max(len(i.attribute_str()) for i in self.table),len(attr_name))
        #print table header
        print("{0:3s} | {1:^{2}s} | {3:^{4}s} | {5:^{6}s} | {7:^{8}} | {9:s}".format(" No", sym_name, sym_len, kind_name, kind_len, type_name, type_len, attr_name, attr_len, "Parameters"))
        print("-----------------------------" + "-" * (sym_len + kind_len + type_len + attr_len))
        #print symbol table
        for i,sym in enumerate(self.table):
            parameters = ""
            for p in sym.param_types:
                if parameters == "":
                    parameters = "{0}".format(SharedData.TYPES[p])
                else:
                    parameters += ", {0}".format(SharedData.TYPES[p])
            print("{0:3d} | {1:^{2}s} | {3:^{4}s} | {5:^{6}s} | {7:^{8}} | ({9})".format(i, sym.name, sym_len, SharedData.KINDS[sym.kind], kind_len, SharedData.TYPES[sym.type], type_len, sym.attribute_str(), attr_len, parameters))
556659
def print_(rows, limit=15, sort='size', order='descending'):
    
    localrows = []
    for row in rows:
        localrows.append(list(row))
    # input validation
    sortby = ['type', '#', 'size']
    if sort not in sortby:
        raise ValueError("invalid sort, should be one of" + str(sortby))
    orders = ['ascending', 'descending']
    if order not in orders:
        raise ValueError("invalid order, should be one of" + str(orders))
    # sort rows
    if sortby.index(sort) == 0:
        if order == "ascending":
            localrows.sort(key=lambda x: _repr(x[0]))
        elif order == "descending":
            localrows.sort(key=lambda x: _repr(x[0]), reverse=True)
    else:
        if order == "ascending":
            localrows.sort(key=lambda x: x[sortby.index(sort)])
        elif order == "descending":
            localrows.sort(key=lambda x: x[sortby.index(sort)], reverse=True)
    # limit rows
    localrows = localrows[0:limit]
    for row in localrows:
        row[2] = stringutils.pp(row[2])
    # print rows
    localrows.insert(0,["types", "# objects", "total size"])
    _print_table(localrows)
1097400
def _layout(dict_vars, dict_vars_extra):
    """"""
    desc = [(v, m.description) for v, m in dict_vars.items()]
    desc.extend((v, baredoc(m.description))
                for v, m in dict_vars_extra.items())
    _pretty_print(desc, min_col_width=26)
1349725
def optimizor(molecules, sort_order, ensemble_size, options):
    
    # set variables
    ncpu = options.ncpu
    score_field = options.score_field

    # generate an exhaustive list of all possible ensembles
    ensemble_list = make_ensemble_list(molecules, score_field, ensemble_size)

    # set number of processors.
    if not ncpu:
        ncpu = multiprocessing.cpu_count()

    if ncpu > 1:
        print("Determining the performance of {d} ensembles using {n} processors".format(d=len(ensemble_list), n=ncpu))

        if ncpu > len(ensemble_list):
            ncpu = len(ensemble_list)

        jobs = []
        output_queue = multiprocessing.Queue()

        for ensemble_chunk in chunker(ensemble_list, ncpu):
            p = multiprocessing.Process(target=evaluate,
                                        args=(molecules, ensemble_chunk, sort_order, options, output_queue))
            jobs.append(p)
            p.start()

        # collect results into a dictionary
        results = {}
        for i in range(len(jobs)):
            results.update(output_queue.get())

        # stop jobs
        for j in jobs:
            j.join()

    else:
        print("Determining the performance of {d} ensembles using {n} processor".format(d=len(ensemble_list), n=ncpu))
        results = evaluate(molecules, ensemble_list, sort_order, options)

    # peel away the best performing ensemble
    ensemble = screener.find_best_ensemble(results, options)

    # write out the best performing ensemble
    output.write_ensemble(list(ensemble), options)

    # temp 2/9/15 generate and return a list of auc values and ef at fpf = 0.001 to build up a histogram
    nd = max([results[x].ef.keys() for x in results.keys()][0])
    n = int(round(0.001 * nd))
    ef_list = [results[x].get_prop(n, 'ef') for x in results.keys()]
    auc_list = [results[x].get_prop('auc') for x in results.keys()]
    # auc_list = [[results[x].get_prop('auc'), results[x].get_prop('ensemble')] for x in results.keys()]
    return auc_list, ef_list
772292
def _print_bits(self,norm=2.3, height=8.0):
        
        bits   = []
        tots   = []
        str    = []
        for i in range(self.width):
            D = {}
            tot = 0
            for letter in ['A', 'C', 'T', 'G']:
                if self.logP:
                    Pij = pow(2.0, self.logP[i][letter])
                else:
                    Pij = pow(2.0, self.ll[i][letter]) * self.background[letter]
                if Pij > 0.01:
                    '''Old'''
                    D[letter] = Pij * self.ll[i][letter]
                    #'''new'''
                    #Q = self.background[letter]
                    #D[letter] = ( Pij * math.log(Pij) - Pij * math.log(Q) ) / math.log(2.0)
                    '''for both old and new'''
                    tot = tot + D[letter]
            bits.append(D)
            tots.append(tot)
        for i in range(self.width):
            s = []
            _l = bits[i].keys()
            _l.sort(lambda x,y,D=bits[i]: cmp(D[y],D[x]))
            for key in _l:
                for j in range(int(bits[i][key] / norm * height)):
                    s.append(key)
            str.append(''.join(s))
        fmt = '%%%ds'%height
        print '#  %s'%('-'*self.width)
        for h in range(int(height)):
            sys.stdout.write("#  ")
            for i in range(self.width):
                sys.stdout.write((fmt%str[i])[h])
            if h == 0:
                sys.stdout.write(' -- %4.2f bits\n'%norm)
            elif h == height-1:
                sys.stdout.write(' -- %4.2f bits\n'%(norm/height))
            else:
                sys.stdout.write('\n')
        print '#  %s'%('-'*self.width)
        print '#  %s'%self.oneletter
721693
def format_output(groups, flag):
    """"""
    out = []
    line_format = '{0}\t{1}\t{2}\t{3}\t{4}\t{5}'
    for g in groups['AutoScalingGroups']:
        out.append(line_format.format(
            g['AutoScalingGroupName'],
            g['LaunchConfigurationName'],
            'desired:'+str(g['DesiredCapacity']),
            'max:'+str(g['MaxSize']),
            'min:'+str(g['MinSize']),
            g['CreatedTime'].strftime('%Y/%m/%d %H:%M:%S'),
        ))
    return out
758685
def show(self):
        
        off = 0
        for n, i in enumerate(self.get_instructions()):
            print("{:8d} (0x{:08x}) {:04x} {:30} {}".format(n, off, i.get_op_value(), i.get_name(), i.get_output(self.idx)))
            off += i.get_length()
1142433
def demo_supercut(composition, padding):
    """"""
    for i, c in enumerate(composition):
        line = c['line']
        start = c['start']
        end = c['end']
        if i > 0 and composition[i - 1]['file'] == c['file'] and start < composition[i - 1]['end']:
            start = start + padding
        print("{1} to {2}:\t{0}".format(line, start, end))
125607
def _groups_of_size(iterable, n, fillvalue=None):
    """"""
    # _groups_of_size('ABCDEFG', 3, 'x') --> ABC DEF Gxx
    args = [iter(iterable)] * n
    return zip_longest(fillvalue=fillvalue, *args)
1314260
def print_continuum(self):
        
        numpoints = len(self.runtime._keys)
        if numpoints:
            print('Numpoints in continuum: {}'.format(numpoints))
        else:
            print('Continuum empty')
        for p in self.get_points():
            point, node = p
            print('{} ({})'.format(node, point))
329870
function printFileSizes(stats, previousSizeMap) {
    const assets = stats.toJson().assets
    .filter((asset) => (/\.(js|css)$/.test(asset.name)))
    .map((asset) => {
        const fileContents = fs.readFileSync(`${paths.appBuild}/${asset.name}`);
        const size = gzipSize(fileContents);
        const previousSize = previousSizeMap[removeFileNameHash(asset.name)];
        const difference = getDifferenceLabel(size, previousSize);
        return {
            folder: path.join('build', path.dirname(asset.name)),
            name: path.basename(asset.name),
            size: size,
            sizeLabel: filesize(size) + (difference ? ` (${difference})` : '')
        };
    });

    assets.sort((a, b) => b.size - a.size);

    const longestSizeLabelLength = Math.max.apply(null,
        assets.map((a) => stripAnsi(a.sizeLabel).length)
    );

    assets.forEach((asset) => {
        let sizeLabel = asset.sizeLabel;
        const sizeLength = stripAnsi(sizeLabel).length;
        if (sizeLength < longestSizeLabelLength) {
            const rightPadding = ' '.repeat(longestSizeLabelLength - sizeLength);
            sizeLabel += rightPadding;
        }
        console.log(sizeLabel, chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name));
    });
}
1119804
def table_print(classes, table):
    
    classes_len = len(classes)
    table_list = []
    for key in classes:
        table_list.extend(list(table[key].values()))
    table_list.extend(classes)
    table_max_length = max(map(len, map(str, table_list)))
    shift = "%-" + str(7 + table_max_length) + "s"
    result = shift % "Predict" + shift * \
        classes_len % tuple(map(str, classes)) + "\n"
    result = result + "Actual\n"
    classes.sort()
    for key in classes:
        row = [table[key][i] for i in classes]
        result += shift % str(key) + \
            shift * classes_len % tuple(map(str, row)) + "\n\n"
    if classes_len >= CLASS_NUMBER_THRESHOLD:
        result += "\n" + "Warning : " + CLASS_NUMBER_WARNING + "\n"
    return result
785048
def print_collection(self, c, h, n):
        """"""
        if c in h:
            return "[]..."
        h.append(c)
        s = []
        for item in c:
            s.append("\n")
            s.append(self.indent(n))
            s.append(self.process(item, h, n - 2))
            s.append(",")
        h.pop()
        return "".join(s)
629047
def toc_print(self):
        """"""
        res = self.toc()
        for n, k, v in res:
            logging.info('Batch: {:7d} {:30s} {:s}'.format(n, k, v))
630478
public void printFullFeatureMatrix(PrintWriter pw) {
    String sep = "\t";
    for (int i = 0; i < featureIndex.size(); i++) {
      pw.print(sep + featureIndex.get(i));
    }
    pw.println();
    for (int i = 0; i < labels.length; i++) {
      pw.print(labelIndex.get(i));
      Set<Integer> feats = new HashSet<Integer>();
      for (int j = 0; j < data[i].length; j++) {
        int feature = data[i][j];
        feats.add(Integer.valueOf(feature));
      }
      for (int j = 0; j < featureIndex.size(); j++) {
        if (feats.contains(Integer.valueOf(j))) {
          pw.print(sep + '1');
        } else {
          pw.print(sep + '0');
        }
      }
    }
  }