Generate ColumnDataSource dictionary for segment labels.
499899
def _get_seg_labels_data(self, order_seg, bins_seg):
        

        if self.xticks is None:
            return dict(x=[], y=[], text=[], angle=[])

        mapping = self._compute_tick_mapping("angle", order_seg, bins_seg)

        values = [(text, ((end - start) / 2) + start)
                  for text, (start, end) in mapping.items()]

        labels, radiant = zip(*values)
        radiant = np.array(radiant)

        y_coord = np.sin(radiant) * self.max_radius + self.max_radius
        x_coord = np.cos(radiant) * self.max_radius + self.max_radius

        return dict(x=x_coord,
                    y=y_coord,
                    text=labels,
                    angle=1.5 * np.pi + radiant)
296552
def _label_columns_json(self):
        
        ret = {}
        for key, value in list(self.label_columns.items()):
            ret[key] = as_unicode(value.encode("UTF-8"))
        return ret
1021012
def _column_names(self):
        """"""
        index_names = set(_normalize_index_names(self._index_names))
        column_names = [col_name for col_name in self._schema_rdd.columns if
                        col_name not in index_names]
        return column_names
153806
def process_schema(doc, resource, df):
    """"""
    from rowgenerators import SourceError
    from requests.exceptions import ConnectionError

    from metapack.cli.core import extract_path_name, alt_col_name, type_map
    from tableintuit import TypeIntuiter
    from rowgenerators.generator.python import PandasDataframeSource
    from appurl import parse_app_url

    try:
        doc['Schema']
    except KeyError:
        doc.new_section('Schema', ['DataType', 'Altname', 'Description'])

    schema_name = resource.get_value('schema', resource.get_value('name'))

    schema_term = doc.find_first(term='Table', value=schema_name, section='Schema')

    if schema_term:
        logger.info("Found table for '{}'; skipping".format(schema_name))
        return

    path, name = extract_path_name(resource.url)

    logger.info("Processing {}".format(resource.url))

    si = PandasDataframeSource(parse_app_url(resource.url), df, cache=doc._cache, )

    try:
        ti = TypeIntuiter().run(si)
    except SourceError as e:
        logger.warn("Failed to process '{}'; {}".format(path, e))
        return
    except ConnectionError as e:
        logger.warn("Failed to download '{}'; {}".format(path, e))
        return

    table = doc['Schema'].new_term('Table', schema_name)

    logger.info("Adding table '{}' to metatab schema".format(schema_name))

    for i, c in enumerate(ti.to_rows()):
        raw_alt_name = alt_col_name(c['header'], i)
        alt_name = raw_alt_name if raw_alt_name != c['header'] else ''

        t = table.new_child('Column', c['header'],
                            datatype=type_map.get(c['resolved_type'], c['resolved_type']),
                            altname=alt_name,
                            description=df[c['header']].description \
                                        if hasattr(df, 'description') and df[c['header']].description else ''
                            )

    return table
403506
def _get_schema(self):
		
		d={}
		layout_kwargs=dict((_,'') for _ in get_layout_kwargs())
		for _ in ('data','layout','theme','panels'):
			d[_]={}
			for __ in eval('__QUANT_FIGURE_{0}'.format(_.upper())):
				layout_kwargs.pop(__,None)
				d[_][__]=None
		d['layout'].update(annotations=dict(values=[],
											params=utils.make_dict_from_list(get_annotation_kwargs())))
		d['layout'].update(shapes=utils.make_dict_from_list(get_shapes_kwargs()))
		[layout_kwargs.pop(_,None) for _ in get_annotation_kwargs()+get_shapes_kwargs()]
		d['layout'].update(**layout_kwargs)
		return d
1289677
def from_columns_dict(cls, columns):
        """"""
        warnings.warn("Table.from_columns_dict is deprecated. Use Table().with_columns(...)", FutureWarning)
        return cls().with_columns(columns.items())
704900
def get_column_labels(obj):
    
    if not isinstance(obj, (list, tuple, pd.np.ndarray)):
        try:
            labels = [f.name for f in obj.model._meta.fields]
        except:
            try:
                labels = obj.keys()
            except:
                try:
                    labels = dir(obj)
                except:
                    labels = None
    elif all(isinstance(heading, basestring) for heading in obj[0]):
        labels = list(obj[0])
        # if obj isn't a reference to a mutable (dict, DataFrame, list, etc), this won't work
        del obj[0]
    return labels
637323
def labels(self, values):
        """"""
        if isinstance(values, dict):
            if self.__data is not None and len(self.__data) != len(values):
                raise ValueError(
                    'number of samples do not match the previously assigned data')
            elif set(self.keys) != set(list(values)):
                raise ValueError('sample ids do not match the previously assigned ids.')
            else:
                self.__labels = values
        else:
            raise ValueError('labels input must be a dictionary!')
926601
def _compute_labels(self, element, data, mapping):
        
        if element.vdims:
            edges = Dataset(element)[element[element.vdims[0].name]>0]
            nodes = list(np.unique([edges.dimension_values(i) for i in range(2)]))
            nodes = element.nodes.select(**{element.nodes.kdims[2].name: nodes})
        else:
            nodes = element

        label_dim = nodes.get_dimension(self.label_index)
        labels = self.labels
        if label_dim and labels:
            if self.label_index not in [2, None]:
                self.param.warning(
                    "Cannot declare style mapping for 'labels' option "
                    "and declare a label_index; ignoring the label_index.")
        elif label_dim:
            labels = label_dim
        if isinstance(labels, basestring):
            labels = element.nodes.get_dimension(labels)

        if labels is None:
            text = []
        if isinstance(labels, dim):
            text = labels.apply(element, flat=True)
        else:
            text = element.nodes.dimension_values(labels)
            text = [labels.pprint_value(v) for v in text]

        value_dim = element.vdims[0]
        text_labels = []
        for i, node in enumerate(element._sankey['nodes']):
            if len(text):
                label = text[i]
            else:
                label = ''
            if self.show_values:
                value = value_dim.pprint_value(node['value'])
                if label:
                    label = '%s - %s' % (label, value)
                else:
                    label = value
            if value_dim.unit:
                label += ' %s' % value_dim.unit
            if label:
                text_labels.append(label)

        ys = nodes.dimension_values(1)
        nodes = element._sankey['nodes']
        if nodes:
            offset = (nodes[0]['x1']-nodes[0]['x0'])/4.
        else:
            offset = 0
        if self.label_position == 'right':
            xs = np.array([node['x1'] for node in nodes])+offset
        else:
            xs = np.array([node['x0'] for node in nodes])-offset
        data['text_1'] = dict(x=xs, y=ys, text=[str(l) for l in text_labels])
        align = 'left' if self.label_position == 'right' else 'right'
        mapping['text_1'] = dict(text='text', x='x', y='y', text_baseline='middle', text_align=align)
543255
def create_source_table(scan_shape):
    

    cols_dict = collections.OrderedDict()
    cols_dict['Source_Name'] = dict(dtype='S48', format='%s')
    cols_dict['name'] = dict(dtype='S48', format='%s')
    cols_dict['class'] = dict(dtype='S32', format='%s')
    cols_dict['SpectrumType'] = dict(dtype='S32', format='%s')
    cols_dict['SpatialType'] = dict(dtype='S32', format='%s')
    cols_dict['SourceType'] = dict(dtype='S32', format='%s')
    cols_dict['SpatialModel'] = dict(dtype='S32', format='%s')
    cols_dict['RAJ2000'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['DEJ2000'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['GLON'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['GLAT'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['ts'] = dict(dtype='f8', format='%.3f')
    cols_dict['loglike'] = dict(dtype='f8', format='%.3f')
    cols_dict['npred'] = dict(dtype='f8', format='%.3f')
    cols_dict['offset'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['offset_ra'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['offset_dec'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['offset_glon'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['offset_glat'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['offset_roi_edge'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['pivot_energy'] = dict(dtype='f8', format='%.3f', unit='MeV')
    cols_dict['flux_scan'] = dict(dtype='f8', format='%.3f',
                                  shape=scan_shape)
    cols_dict['eflux_scan'] = dict(dtype='f8', format='%.3f',
                                   shape=scan_shape)
    cols_dict['norm_scan'] = dict(dtype='f8', format='%.3f',
                                  shape=scan_shape)
    cols_dict['dloglike_scan'] = dict(dtype='f8', format='%.3f',
                                      shape=scan_shape)
    cols_dict['loglike_scan'] = dict(dtype='f8', format='%.3f',
                                     shape=scan_shape)

    # Add source dictionary columns
    for k, v in sorted(defaults.source_output.items()):
        if not k in cols_dict.keys():
            if v[2] == float:
                cols_dict[k] = dict(dtype='f8', format='%f')
            elif k == 'Spectrum_Filename' or k == 'Spatial_Filename':
                cols_dict[k] = dict(dtype='S128', format='%s')
            elif v[2] == str:
                cols_dict[k] = dict(dtype='S32', format='%s')

    cols_dict['param_names'] = dict(dtype='S32', format='%s', shape=(10,))
    cols_dict['param_values'] = dict(dtype='f8', format='%f', shape=(10,))
    cols_dict['param_errors'] = dict(dtype='f8', format='%f', shape=(10,))

    # Catalog Parameters
    cols_dict['Flux_Density'] = dict(
        dtype='f8', format='%.5g', unit='1 / (MeV cm2 s)')
    cols_dict['Spectral_Index'] = dict(dtype='f8', format='%.3f')
    cols_dict['Pivot_Energy'] = dict(dtype='f8', format='%.3f', unit='MeV')
    cols_dict['beta'] = dict(dtype='f8', format='%.3f')
    cols_dict['Exp_Index'] = dict(dtype='f8', format='%.3f')
    cols_dict['Cutoff'] = dict(dtype='f8', format='%.3f', unit='MeV')
    cols_dict['Expfactor'] = dict(dtype='f8', format='%.3f')

    cols_dict['Conf_68_PosAng'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['Conf_68_SemiMajor'] = dict(
        dtype='f8', format='%.3f', unit='deg')
    cols_dict['Conf_68_SemiMinor'] = dict(
        dtype='f8', format='%.3f', unit='deg')
    cols_dict['Conf_95_PosAng'] = dict(dtype='f8', format='%.3f', unit='deg')
    cols_dict['Conf_95_SemiMajor'] = dict(
        dtype='f8', format='%.3f', unit='deg')
    cols_dict['Conf_95_SemiMinor'] = dict(
        dtype='f8', format='%.3f', unit='deg')

    for t in ['eflux', 'eflux100', 'eflux1000', 'eflux10000']:
        cols_dict[t] = dict(dtype='f8', format='%.3f', unit='MeV / (cm2 s)')
        cols_dict[t + '_err'] = dict(dtype='f8',
                                     format='%.3f', unit='MeV / (cm2 s)')

    for t in ['eflux_ul95', 'eflux100_ul95', 'eflux1000_ul95', 'eflux10000_ul95']:
        cols_dict[t] = dict(dtype='f8', format='%.3f', unit='MeV / (cm2 s)')

    for t in ['flux', 'flux100', 'flux1000', 'flux10000']:
        cols_dict[t] = dict(dtype='f8', format='%.3f', unit='1 / (cm2 s)')
        cols_dict[t + '_err'] = dict(dtype='f8',
                                     format='%.3f', unit='1 / (cm2 s)')

    for t in ['flux_ul95', 'flux100_ul95', 'flux1000_ul95', 'flux10000_ul95']:
        cols_dict[t] = dict(dtype='f8', format='%.3f', unit='1 / (cm2 s)')

    for t in ['dnde', 'dnde100', 'dnde1000', 'dnde10000']:
        cols_dict[t] = dict(dtype='f8', format='%.3f', unit='1 / (MeV cm2 s)')
        cols_dict[t + '_err'] = dict(dtype='f8',
                                     format='%.3f', unit='1 / (MeV cm2 s)')

    cols = [Column(name=k, **v) for k, v in cols_dict.items()]
    tab = Table(cols)
    return tab
625773
def colgen(*lstcol,**kargs):
    """"""
    if len(lstcol) < 2:
        lstcol *= 2
    trans = kargs.get("trans", lambda x,y,z: (x,y,z))
    while 1:
        for i in range(len(lstcol)):
            for j in range(len(lstcol)):
                for k in range(len(lstcol)):
                    if i != j or j != k or k != i:
                        yield trans(lstcol[(i+j)%len(lstcol)],lstcol[(j+k)%len(lstcol)],lstcol[(k+i)%len(lstcol)])
259574
def make_column_label(command_name, description, default):
    ''''''
    for (pattern, label) in description_map:
        if fnmatch.fnmatch(description, pattern):
            return label
    return default
395870
def labels_to_indexed_coref_values(content_objs, labels):
    '''
    '''
    cids_to_idx = {}
    for i, (content_id, _) in enumerate(content_objs):
        cids_to_idx[content_id] = i
    idx = lambda cid: cids_to_idx[cid]
    labs = []
    for lab in labels:
        if lab.content_id1 in cids_to_idx and lab.content_id2 in cids_to_idx:
            labs.append((lab.value.value, idx(lab.content_id1), idx(lab.content_id2)))
    return labs
661041
def translate_labels(val):
    '''
    
    '''
    if not isinstance(val, dict):
        if not isinstance(val, list):
            val = split(val)
        new_val = {}
        for item in val:
            if isinstance(item, dict):
                if len(item) != 1:
                    raise SaltInvocationError('Invalid label(s)')
                key = next(iter(item))
                val = item[key]
            else:
                try:
                    key, val = split(item, '=', 1)
                except ValueError:
                    key = item
                    val = ''
            if not isinstance(key, six.string_types):
                key = six.text_type(key)
            if not isinstance(val, six.string_types):
                val = six.text_type(val)
            new_val[key] = val
        val = new_val
    return val
1115681
def to_array(self):
        """"""
        dt = np.dtype(list(zip(self.labels, (c.dtype for c in self.columns))))
        arr = np.empty_like(self.columns[0], dt)
        for label in self.labels:
            arr[label] = self[label]
        return arr
187516
function computeLinesAndColumns(tokenizer, source) {
    var sourceLength = source.length;
    var start = firstCharOffset(source);
    var lines = tokenizer.lines;
    var line = tokenizer.startLine;
    var columns = tokenizer.columns;
    var column = tokenizer.startColumn;

    if (lines === null || lines.length < sourceLength + 1) {
        lines = new SafeUint32Array(Math.max(sourceLength + 1024, MIN_BUFFER_SIZE));
        columns = new SafeUint32Array(lines.length);
    }

    for (var i = start; i < sourceLength; i++) {
        var code = source.charCodeAt(i);

        lines[i] = line;
        columns[i] = column++;

        if (code === N || code === R || code === F) {
            if (code === R && i + 1 < sourceLength && source.charCodeAt(i + 1) === N) {
                i++;
                lines[i] = line;
                columns[i] = column;
            }

            line++;
            column = 1;
        }
    }

    lines[i] = line;
    columns[i] = column;

    tokenizer.linesAnsColumnsComputed = true;
    tokenizer.lines = lines;
    tokenizer.columns = columns;
}
1191263
def auto_labels(df):
    
    systems = list(df.system)
    facets = list(df.facet)
    systems_labels = [w.replace('_', '\ ') for w in systems]
    systems_labels = [sub(w) for w in systems_labels]
    systems_labels = [w.replace('}$$_{', '') for w in systems_labels]
    systems_labels = [w.replace('$', '') for w in systems_labels]
    systems_labels = ['$' + w + '$' for w in systems_labels]

    facets_label = [w.replace('_', '\ ') for w in facets]
    facets_label = ['(' + w + ')' for w in facets_label]

    labels = []
    for i, sys in enumerate(systems_labels):
        labels.append(sys + facets_label[i])
    # labels = list(set(labels))
    return(labels)