Read LexStat object from cldf dataset.
354516
def _cldf2lexstat(
        dataset,
        segments='segments',
        transcription='value',
        row='parameter_id',
        col='language_id'):
    """"""
    D = _cldf2wld(dataset)
    return lingpy.LexStat(D, segments=segments, transcription=transcription, row=row, col=col)
526208
def ReadClientStats(self,
                      client_id,
                      min_timestamp,
                      max_timestamp,
                      cursor=None):
    """"""

    cursor.execute(
        """
        SELECT payload FROM client_stats
        WHERE client_id = %s
          AND timestamp BETWEEN FROM_UNIXTIME(%s) AND FROM_UNIXTIME(%s)
        ORDER BY timestamp ASC
        """, [
            db_utils.ClientIDToInt(client_id),
            mysql_utils.RDFDatetimeToTimestamp(min_timestamp),
            mysql_utils.RDFDatetimeToTimestamp(max_timestamp)
        ])
    return [
        rdf_client_stats.ClientStats.FromSerializedString(stats_bytes)
        for stats_bytes, in cursor.fetchall()
    ]
410127
def _read_family(fname, all_cat, template):
    
    detections = []
    with open(fname, 'r') as f:
        for line in f:
            det_dict = {}
            gen_event = False
            for key_pair in line.rstrip().split(';'):
                key = key_pair.split(': ')[0].strip()
                value = key_pair.split(': ')[-1].strip()
                if key == 'event':
                    if len(all_cat) == 0:
                        gen_event = True
                        continue
                    el = [e for e in all_cat
                          if str(e.resource_id).split('/')[-1] == value][0]
                    det_dict.update({'event': el})
                elif key == 'detect_time':
                    det_dict.update(
                        {'detect_time': UTCDateTime(value)})
                elif key == 'chans':
                    det_dict.update({'chans': ast.literal_eval(value)})
                elif key in ['template_name', 'typeofdet', 'id',
                             'threshold_type']:
                    det_dict.update({key: value})
                elif key == 'no_chans':
                    det_dict.update({key: int(float(value))})
                elif len(key) == 0:
                    continue
                else:
                    det_dict.update({key: float(value)})
            detection = Detection(**det_dict)
            if gen_event:
                detection._calculate_event(template=template)
            detections.append(detection)
    return detections
968934
def load_data(verbose=False):
    ""

    df = pd.read_csv(STOPS_PATH, usecols=['stop_id', 'stop_name'])
    if verbose:
        print('- Loaded %d entries from "%s".' % (len(df), STOPS_PATH))
    return df
639804
def read_pl_dataset(infile):
    

    m, n = [int(i) for i in infile.readline().split(',')]
    gamma = np.array([float(f) for f in infile.readline().split(',')])
    if len(gamma) != m:
        infile.close()
        raise ValueError("malformed file: len(gamma) != m")
    votes = []
    i = 0
    for line in infile:
        vote = [int(v) for v in line.split(',')]
        if len(vote) != m:
            infile.close()
            raise ValueError("malformed file: len(vote) != m")
        votes.append(vote)
        i += 1
    infile.close()
    if i != n:
        raise ValueError("malformed file: number of votes != n")
    return (gamma, np.array(votes))
1091430
def aggregateStatsDF(stats_df):
    ''' '''

    grouped = stats_df.groupby("UMI")

    agg_dict = {'counts': [np.median, len, np.sum]}
    agg_df = grouped.agg(agg_dict)

    agg_df.columns = ['median_counts', 'times_observed', 'total_counts']
    return agg_df
449060
def datagetter(cls):
        
        with open('myfile', 'rt') as f:
            rows = [r for r in csv.reader(f)]
        dothing = lambda _: [i for i, v in enumerate(_)]
        rows = [dothing(_) for _ in rows]
        raise NotImplementedError('You need to implement this yourlself!')
        return rows
648249
def build_dataset(filename, max_lines=-1):
    """"""
    encodings = dict(list(map(reversed, enumerate(string.printable))))
    digitize = lambda char: encodings[char] if char in encodings else len(encodings)
    encode_line = lambda line: np.array(list(map(digitize, line)))
    nonblank_line = lambda line: len(line) > 2

    with open(filename) as f:
        lines = f.readlines()

    encoded_lines = list(map(encode_line, list(filter(nonblank_line, lines))[:max_lines]))
    num_outputs = len(encodings) + 1

    return encoded_lines, num_outputs
1321359
def getStats(jobStore):
    
    def aggregateStats(fileHandle,aggregateObject):
        try:
            stats = json.load(fileHandle, object_hook=Expando)
            for key in list(stats.keys()):
                if key in aggregateObject:
                    aggregateObject[key].append(stats[key])
                else:
                    aggregateObject[key]=[stats[key]]
        except ValueError:
            logger.critical("File %s contains corrupted json. Skipping file." % fileHandle)
            pass  # The file is corrupted.

    aggregateObject = Expando()
    callBack = partial(aggregateStats, aggregateObject=aggregateObject)
    jobStore.readStatsAndLogging(callBack, readAll=True)
    return aggregateObject
1159220
def get_file_stats(file_name, entity_type='file', lineno=None, cursorpos=None,
                   plugin=None, language=None, local_file=None):
    """"""

    language = standardize_language(language, plugin)
    stats = {
        'language': language,
        'dependencies': [],
        'lines': None,
        'lineno': lineno,
        'cursorpos': cursorpos,
    }

    if entity_type == 'file':
        lexer = get_lexer(language)
        if not language:
            language, lexer = guess_language(file_name, local_file)
        parser = DependencyParser(local_file or file_name, lexer)
        stats.update({
            'language': use_root_language(language, lexer),
            'dependencies': parser.parse(),
            'lines': number_lines_in_file(local_file or file_name),
        })

    return stats
604151
def lex(self, text):
        """"""
        for match in self.regex.finditer(text):
            name = match.lastgroup
            yield (name, match.group(name))
836468
def load_corpus(path):
    

    # Check if the data exists, otherwise download or raise
    if not os.path.exists(path):
        raise ValueError((
            "'{}' dataset has not been downloaded, "
            "use the yellowbrick.download module to fetch datasets"
        ).format(path))

    # Read the directories in the directory as the categories.
    categories = [
        cat for cat in os.listdir(path)
        if os.path.isdir(os.path.join(path, cat))
    ]

    files  = [] # holds the file names relative to the root
    data   = [] # holds the text read from the file
    target = [] # holds the string of the category

    # Load the data from the files in the corpus
    for cat in categories:
        for name in os.listdir(os.path.join(path, cat)):
            files.append(os.path.join(path, cat, name))
            target.append(cat)

            with open(os.path.join(path, cat, name), 'r') as f:
                data.append(f.read())


    # Return the data bunch for use similar to the newsgroups example
    return Bunch(
        categories=categories,
        files=files,
        data=data,
        target=target,
    )
254077
def _seqcluster_stats(data, out_dir):
    """"""
    name = dd.get_sample_name(data)
    fn = data.get("seqcluster", {}).get("stat_file", None)
    if not fn:
        return None
    out_file = os.path.join(out_dir, "%s.txt" % name)
    df = pd.read_csv(fn, sep="\t", names = ["reads", "sample", "type"])
    df_sample = df[df["sample"] == name]
    df_sample.to_csv(out_file, sep="\t")
    return out_file
1050263
def __read_lipd_contents():
    
    global files, settings
    _d = {}
    try:
        if len(files[".lpd"]) == 1:
            _d = lipd_read(files[".lpd"][0]["full_path"])
            if settings["verbose"]:
                print("Finished read: 1 record")
        else:
            for file in files[".lpd"]:
                _d[file["filename_no_ext"]] = lipd_read(file["full_path"])
            if settings["verbose"]:
                print("Finished read: {} records".format(len(_d)))
    except Exception as e:
        print("Error: read_lipd_contents: {}".format(e))
    return _d
320955
private static DataSet<Tuple2<String, String>> getDocumentsDataSet(ExecutionEnvironment env, ParameterTool params) {
		// Create DataSet for documents relation (URL, Doc-Text)
		if (params.has("documents")) {
			return env.readCsvFile(params.get("documents"))
						.fieldDelimiter("|")
						.types(String.class, String.class);
		} else {
			System.out.println("Executing WebLogAnalysis example with default documents data set.");
			System.out.println("Use --documents to specify file input.");
			return WebLogData.getDocumentDataSet(env);
		}
	}
793367
def load_data(self, pdbid):
        """"""
        f = urlopen("http://projects.biotec.tu-dresden.de/plip-rest/pdb/%s?format=xml" % pdbid.lower())
        self.doc = etree.parse(f)
1050021
public void readData(BufferedReader in) throws IOException {
    String line, value;
    // skip old variables if still present
    lexOptions.readData(in);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    try {
      tlpParams = (TreebankLangParserParams) Class.forName(value).newInstance();
    } catch (Exception e) {
      IOException ioe = new IOException("Problem instantiating parserParams: " + line);
      ioe.initCause(e);
      throw ioe;
    }
    line = in.readLine();
    // ensure backwards compatibility
    if (line.matches("^forceCNF.*")) {
      value = line.substring(line.indexOf(' ') + 1);
      forceCNF = Boolean.parseBoolean(value);
      line = in.readLine();
    }
    value = line.substring(line.indexOf(' ') + 1);
    doPCFG = Boolean.parseBoolean(value);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    doDep = Boolean.parseBoolean(value);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    freeDependencies = Boolean.parseBoolean(value);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    directional = Boolean.parseBoolean(value);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    genStop = Boolean.parseBoolean(value);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    distance = Boolean.parseBoolean(value);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    coarseDistance = Boolean.parseBoolean(value);
    line = in.readLine();
    value = line.substring(line.indexOf(' ') + 1);
    dcTags = Boolean.parseBoolean(value);
    line = in.readLine();
    if ( ! line.matches("^nPrune.*")) {
      throw new RuntimeException("Expected nPrune, found: " + line);
    }
    value = line.substring(line.indexOf(' ') + 1);
    nodePrune = Boolean.parseBoolean(value);
    line = in.readLine(); // get rid of last line
    if (line.length() != 0) {
      throw new RuntimeException("Expected blank line, found: " + line);
    }
  }