c8867b6e46695ea5f7bd9ecfed44b35d42df38c4,mir_eval/io.py,,load_patterns,#Any#,264
Before Change
P = [[[(77.0, 67.0), (77.5, 77.0), ... ]]]
with open(filename, "r") as input_file:
// List with all the patterns
pattern_list = []
// Current pattern, which will contain all occs
pattern = []
// Current occurrence, containing (onset, midi)
occurrence = []
for line in input_file.readlines():
if "pattern" in line:
if occurrence != []:
pattern.append(occurrence)
if pattern != []:
pattern_list.append(pattern)
occurrence = []
pattern = []
continue
if "occurrence" in line:
if occurrence != []:
pattern.append(occurrence)
occurrence = []
continue
string_values = line.split(",")
onset_midi = (float(string_values[0]), float(string_values[1]))
occurrence.append(onset_midi)
// Add last occurrence and pattern to pattern_list
if occurrence != []:
pattern.append(occurrence)
if pattern != []:
pattern_list.append(pattern)
return pattern_list
def load_wav(path, mono=True):
After Change
// Keep track of whether we create our own file handle
own_fh = False
// If the filename input is a string, need to open it
if type(filename) == str:
// Remember that we need to close it later
own_fh = True
// 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")
// List with all the patterns
pattern_list = []
// Current pattern, which will contain all occs
pattern = []
// Current occurrence, containing (onset, midi)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
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
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: facebookresearch/ParlAI
Commit Name: c228fc1c648602f93c078298f9e363f6e02694d2
Time: 2017-12-15
Author: ahm@fb.com
File Name: parlai/core/metrics.py
Class Name: Metrics
Method Name: update