3e34690bca279c672505a58212746c8053595412,mir_eval/io.py,,load_delimited,#Any#Any#Any#,13
Before Change
//
// 2. numpy"s text loader does not handle non-numeric data
//
with open(filename, "r") as input_file:
for row, line in enumerate(input_file, 1):
// Split each line using the supplied delimiter
data = splitter.split(line.strip(), n_columns - 1)
// Throw a helpful error if we got an unexpected // of columns
if n_columns != len(data):
raise ValueError("Expected {} columns, got {} at "
"{}:{:d}:\n\t{}".format(n_columns, len(data),
filename, row, line))
for value, column, converter in zip(data, columns, converters):
// Try converting the value, throw a helpful error on failure
try:
converted_value = converter(value)
except:
raise ValueError("Couldn"t convert value {} using {} "
"found at {}:{:d}:\n\t{}".format(
value, converter.__name__, filename,
row, line))
column.append(converted_value)
// Sane output
if n_columns == 1:
return columns[0]
else:
return columns
After Change
// Open the file for reading
input_file = open(filename, "r")
// If the provided has a read attribute, we can use it as a file handle
elif hasattr(filename, "read"):
input_file = filename
// Raise error otherwise
else:
raise ValueError("filename must be a string or file handle")
// Note: we do io manually here for two reasons.
// 1. The csv module has difficulties with unicode, which may lead
// to failures on certain annotation strings
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: craffel/mir_eval
Commit Name: 3e34690bca279c672505a58212746c8053595412
Time: 2014-10-28
Author: craffel@gmail.com
File Name: mir_eval/io.py
Class Name:
Method Name: load_delimited
Project Name: has2k1/plotnine
Commit Name: 565bfe890fa85b433bf1be04189212000b3cd327
Time: 2016-04-13
Author: has2k1@gmail.com
File Name: ggplot/geoms/geom.py
Class Name: geom
Method Name: _make_stat
Project Name: craffel/mir_eval
Commit Name: c8867b6e46695ea5f7bd9ecfed44b35d42df38c4
Time: 2014-10-28
Author: craffel@gmail.com
File Name: mir_eval/io.py
Class Name:
Method Name: load_patterns