Partition data sources into

    1. Dictionary of data sources associated with radio sources.
    2. List of data sources to feed multiple times.
    3. List of data sources to feed once.
966173
def _partition(iter_dims, data_sources):
    

    src_nr_vars = set(source_var_types().values())
    iter_dims = set(iter_dims)

    src_data_sources = collections.defaultdict(list)
    feed_many = []
    feed_once = []

    for ds in data_sources:
        # Is this data source associated with
        # a radio source (point, gaussian, etc.?)
        src_int = src_nr_vars.intersection(ds.shape)

        if len(src_int) > 1:
            raise ValueError("Data source '{}' contains multiple "
                            "source types '{}'".format(ds.name, src_int))
        elif len(src_int) == 1:
            # Yep, record appropriately and iterate
            src_data_sources[src_int.pop()].append(ds)
            continue

        # Are we feeding this data source multiple times
        # (Does it possess dimensions on which we iterate?)
        if len(iter_dims.intersection(ds.shape)) > 0:
            feed_many.append(ds)
            continue

        # Assume this is a data source that we only feed once
        feed_once.append(ds)

    return src_data_sources, feed_many, feed_once
1069000
def clean_sources(self):
        

        for src in self.dataset.sources:
            src.st_id = None
            src.t_id = None

        self.dataset.sources[:] = []
        self.dataset.source_tables[:] = []
        self.dataset.st_sequence_id = 1
143773
def split_metadata(data, splitter, name_value_delimiter = '=')
      hash = {}
      data.to_s.split(splitter).each do |pair|
        name, value = pair.split(name_value_delimiter, 2)
        hash[name.strip] = value.strip if name && value
      end
      hash
    end
565730
def _update_datasource(self, source, data):
        
        if not self.document:
            return

        data = self._postprocess_data(data)
        empty = all(len(v) == 0 for v in data.values())
        if (self.streaming and self.streaming[0].data is self.current_frame.data
            and self._stream_data and not empty):
            stream = self.streaming[0]
            if stream._triggering:
                data = {k: v[-stream._chunk_length:] for k, v in data.items()}
                source.stream(data, stream.length)
            return

        if cds_column_replace(source, data):
            source.data = data
        else:
            source.data.update(data)
1035287
def analyze_chunks(data, freq, bits, chunksize=512):
    
    res = []
    while data != []:
        f = find_frequencies(data[:chunksize], freq, bits)
        res.append(sorted(find_notes(f), key=operator.itemgetter(1))[-1][0])
        data = data[chunksize:]
    return res
538288
public List<DataSourceType<WebFragmentDescriptor>> getAllDataSource()
   {
      List<DataSourceType<WebFragmentDescriptor>> list = new ArrayList<DataSourceType<WebFragmentDescriptor>>();
      List<Node> nodeList = model.get("data-source");
      for(Node node: nodeList)
      {
         DataSourceType<WebFragmentDescriptor>  type = new DataSourceTypeImpl<WebFragmentDescriptor>(this, "data-source", model, node);
         list.add(type);
      }
      return list;
   }
95991
def _collect_data(directory):
  
  # Returns:
  data_files = []
  transcripts = [
      filename for filename in os.listdir(directory)
      if filename.endswith(".csv")
  ]
  for transcript in transcripts:
    transcript_path = os.path.join(directory, transcript)
    with open(transcript_path, "r") as transcript_file:
      transcript_reader = csv.reader(transcript_file)
      # skip header
      _ = next(transcript_reader)
      for transcript_line in transcript_reader:
        media_name, label = transcript_line[0:2]
        filename = os.path.join(directory, media_name)
        data_files.append((media_name, filename, label))
  return data_files
45316
def feed(self, data):
        
        """
        self.rawdata = self.rawdata + data
        self.goahead(0)
1040474
def split_data(data, subset, splits):
  '''
  '''

  return dict([(k, data[k][splits[subset]]) for k in data])
1141718
def sorted_feed_cols(df):
    
    cols = df.columns
    ind = [int(c.split("feed")[1]) for c in cols]
    cols = zip(ind,cols)
    cols.sort()
    cols = [c[1] for c in cols]
    return cols
138630
def compress(self, data_list):
        
        data = {}
        if data_list:
            return dict(
                (f.name, data_list[i]) for i, f in enumerate(self.form))
        return data
833368
function resources(data) {
    var items = [],
        fid = schedule.functor(id),
        favailable = schedule.functor(available),
        freserve = schedule.functor(isNotReservable);

    for(var i = 0, len = data.length; i < len; i++) {
      var resource = data[i],
          rId = fid.call(this, resource, i),
          rAvailable = favailable.call(this, resource, i),
          rReserve = freserve.call(this, resource, i);

      items.push({id: rId, available: rAvailable, isNotReservable: rReserve});
    }

    return items;
  }
902965
def _get_data_from_list_of_dicts(source, fields='*', first_row=0, count=-1, schema=None):
  
  if schema is None:
    schema = google.datalab.bigquery.Schema.from_data(source)
  fields = get_field_list(fields, schema)
  gen = source[first_row:first_row + count] if count >= 0 else source
  rows = [{'c': [{'v': row[c]} if c in row else {} for c in fields]} for row in gen]
  return {'cols': _get_cols(fields, schema), 'rows': rows}, len(source)
450824
def dataset_to_rdf(dataset, graph=None):
    '''
    
    '''
    # Use the unlocalized permalink to the dataset as URI when available
    # unless there is already an upstream URI
    if 'uri' in dataset.extras:
        id = URIRef(dataset.extras['uri'])
    elif dataset.id:
        id = URIRef(url_for('datasets.show_redirect',
                            dataset=dataset.id,
                            _external=True))
    else:
        id = BNode()
    # Expose upstream identifier if present
    if 'dct:identifier' in dataset.extras:
        identifier = dataset.extras['dct:identifier']
    else:
        identifier = dataset.id
    graph = graph or Graph(namespace_manager=namespace_manager)

    d = graph.resource(id)
    d.set(RDF.type, DCAT.Dataset)
    d.set(DCT.identifier, Literal(identifier))
    d.set(DCT.title, Literal(dataset.title))
    d.set(DCT.description, Literal(dataset.description))
    d.set(DCT.issued, Literal(dataset.created_at))
    d.set(DCT.modified, Literal(dataset.last_modified))

    if dataset.acronym:
        d.set(SKOS.altLabel, Literal(dataset.acronym))

    for tag in dataset.tags:
        d.add(DCAT.keyword, Literal(tag))

    for resource in dataset.resources:
        d.add(DCAT.distribution, resource_to_rdf(resource, dataset, graph))

    if dataset.owner:
        d.add(DCT.publisher, user_to_rdf(dataset.owner, graph))
    elif dataset.organization:
        d.add(DCT.publisher, organization_to_rdf(dataset.organization, graph))

    if dataset.temporal_coverage:
        d.set(DCT.temporal, temporal_to_rdf(dataset.temporal_coverage, graph))

    frequency = frequency_to_rdf(dataset.frequency)
    if frequency:
        d.set(DCT.accrualPeriodicity, frequency)

    return d
540787
def make_data_splits(label_type, train_rec_type="text_and_wordlist", max_samples=1000,
                     seed=0, tgt_dir=TGT_DIR):
    

    feat_dir = os.path.join(tgt_dir, "feat")
    test_prefix_fn=os.path.join(tgt_dir, "test_prefixes.txt")
    valid_prefix_fn=os.path.join(tgt_dir, "valid_prefixes.txt")
    with open(test_prefix_fn) as f:
        prefixes = f.readlines()
        test_prefixes = [("TEXT/" + prefix).strip() for prefix in prefixes]
    with open(valid_prefix_fn) as f:
        prefixes = f.readlines()
        valid_prefixes = [("TEXT/" + prefix).strip() for prefix in prefixes]

    label_dir = os.path.join(tgt_dir, "label")
    prefixes = get_story_prefixes(label_type, label_dir=label_dir)
    prefixes = list(set(prefixes) - set(valid_prefixes))
    prefixes = list(set(prefixes) - set(test_prefixes))
    prefixes = utils.filter_by_size(
        feat_dir, prefixes, "fbank", max_samples)

    if train_rec_type == "text":
        train_prefixes = prefixes
    else:
        wordlist_prefixes = [prefix for prefix in os.listdir(os.path.join(label_dir, "WORDLIST"))
                             if prefix.endswith("phonemes")]
        wordlist_prefixes = [os.path.splitext(os.path.join("WORDLIST", prefix))[0]
                             for prefix in wordlist_prefixes]
        wordlist_prefixes = utils.filter_by_size(
                feat_dir, wordlist_prefixes, "fbank", max_samples)
        if train_rec_type == "wordlist":
            prefixes = wordlist_prefixes
        elif train_rec_type == "text_and_wordlist":
            prefixes.extend(wordlist_prefixes)
        else:
            raise PersephoneException("train_rec_type='%s' not supported." % train_rec_type)
        train_prefixes = prefixes
    random.seed(seed)
    random.shuffle(train_prefixes)

    return train_prefixes, valid_prefixes, test_prefixes
514775
def list_feeds(self):
        
        feeds = configparser.ConfigParser()
        feeds.read(self.data_filename)
        return feeds.sections()
230824
def _concat(self, first_data, second_data):
        """"""
        assert len(first_data) == len(
            second_data), 'data source should contain the same size'
        if first_data and second_data:
            return [
                concat(
                    first_data[x],
                    second_data[x],
                    dim=0
                ) for x in range(len(first_data))
            ]
        elif (not first_data) and (not second_data):
            return []
        else:
            return [
                first_data[0] if first_data else second_data[0]
                for x in range(len(first_data))
            ]