# Path: note_seq/melody_inference.py
# REST = -1
# MELODY_VELOCITY = 127
# MAX_NUM_FRAMES = 10000
# def _melody_transition_distribution(rest_prob, interval_prob_fn):
# def sequence_note_frames(sequence):
# def _melody_frame_log_likelihood(pitches, has_onsets, has_notes, durations,
#                                  instantaneous_non_max_pitch_prob,
#                                  instantaneous_non_empty_rest_prob,
#                                  instantaneous_missing_pitch_prob):
# def _melody_viterbi(pitches, melody_frame_loglik, melody_transition_loglik):
#   def index_to_event(i):
# def infer_melody_for_sequence(sequence,
#                               melody_interval_scale=2.0,
#                               rest_prob=0.1,
#                               instantaneous_non_max_pitch_prob=1e-15,
#                               instantaneous_non_empty_rest_prob=0.0,
#                               instantaneous_missing_pitch_prob=1e-15):
#   def add_note(start_time, end_time, pitch):
# class MelodyInferenceError(Exception):  # pylint:disable=g-bad-exception-name
# 
# Path: note_seq/testing_lib.py
# BEAT = music_pb2.NoteSequence.TextAnnotation.BEAT
# CHORD_SYMBOL = music_pb2.NoteSequence.TextAnnotation.CHORD_SYMBOL
# def add_track_to_sequence(note_sequence,
#                           instrument,
#                           notes,
#                           is_drum=False,
#                           program=0):
# def add_chords_to_sequence(note_sequence, chords):
# def add_key_signatures_to_sequence(note_sequence, keys):
# def add_beats_to_sequence(note_sequence, beats, beats_per_bar=None):
# def add_control_changes_to_sequence(note_sequence, instrument, control_changes):
# def add_pitch_bends_to_sequence(
#     note_sequence, instrument, program, pitch_bends):
# def add_quantized_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_chord_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_control_steps_to_sequence(sequence, quantized_steps):
#   def __init__(self, num_classes, num_steps=None):
#   def num_classes(self):
#   def default_event(self):
#   def encode_event(self, event):
#   def decode_event(self, index):
#   def event_to_num_steps(self, event):
# def parse_test_proto(proto_type, proto_string):
# def get_testdata_dir():
#   def setUp(self):
#   def _AssertProtoEquals(self, a, b, msg=None):  # pylint:disable=invalid-name
#   def assertProtoEquals(self, expected_message_maybe_ascii, message, msg=None):
# class TrivialOneHotEncoding(encoder_decoder.OneHotEncoding):
# class ProtoTestCase(absltest.TestCase):


from absl.testing import absltest
from note_seq import melody_inference
from note_seq import testing_lib
from note_seq.protobuf import music_pb2
        sequence, 0,
        [(60, 100, 0.5, 2.0), (62, 100, 1.0, 1.25)])

    pitches, has_onsets, has_notes, event_times = (
        melody_inference.sequence_note_frames(sequence))

    expected_pitches = [60, 62]
    expected_has_onsets = [[0, 0], [1, 0], [0, 1], [0, 0]]
    expected_has_notes = [[0, 0], [1, 0], [1, 1], [1, 0]]
    expected_event_times = [0.5, 1.0, 1.25]

    self.assertEqual(expected_pitches, pitches)
    self.assertEqual(expected_has_onsets, has_onsets.tolist())
    self.assertEqual(expected_has_notes, has_notes.tolist())
    self.assertEqual(expected_event_times, event_times)

  def testMelodyInferenceEmptySequence(self):
    sequence = music_pb2.NoteSequence()
    melody_inference.infer_melody_for_sequence(sequence)
    expected_sequence = music_pb2.NoteSequence()
    self.assertEqual(expected_sequence, sequence)

  def testMelodyInferenceSingleNote(self):
    sequence = music_pb2.NoteSequence()
    testing_lib.add_track_to_sequence(
        sequence, 0, [(60, 100, 0.5, 1.0)])

    melody_inference.infer_melody_for_sequence(sequence)

    expected_sequence = music_pb2.NoteSequence()

# Path: note_seq/melody_inference.py
# REST = -1
# MELODY_VELOCITY = 127
# MAX_NUM_FRAMES = 10000
# def _melody_transition_distribution(rest_prob, interval_prob_fn):
# def sequence_note_frames(sequence):
# def _melody_frame_log_likelihood(pitches, has_onsets, has_notes, durations,
#                                  instantaneous_non_max_pitch_prob,
#                                  instantaneous_non_empty_rest_prob,
#                                  instantaneous_missing_pitch_prob):
# def _melody_viterbi(pitches, melody_frame_loglik, melody_transition_loglik):
#   def index_to_event(i):
# def infer_melody_for_sequence(sequence,
#                               melody_interval_scale=2.0,
#                               rest_prob=0.1,
#                               instantaneous_non_max_pitch_prob=1e-15,
#                               instantaneous_non_empty_rest_prob=0.0,
#                               instantaneous_missing_pitch_prob=1e-15):
#   def add_note(start_time, end_time, pitch):
# class MelodyInferenceError(Exception):  # pylint:disable=g-bad-exception-name
# 
# Path: note_seq/testing_lib.py
# BEAT = music_pb2.NoteSequence.TextAnnotation.BEAT
# CHORD_SYMBOL = music_pb2.NoteSequence.TextAnnotation.CHORD_SYMBOL
# def add_track_to_sequence(note_sequence,
#                           instrument,
#                           notes,
#                           is_drum=False,
#                           program=0):
# def add_chords_to_sequence(note_sequence, chords):
# def add_key_signatures_to_sequence(note_sequence, keys):
# def add_beats_to_sequence(note_sequence, beats, beats_per_bar=None):
# def add_control_changes_to_sequence(note_sequence, instrument, control_changes):
# def add_pitch_bends_to_sequence(
#     note_sequence, instrument, program, pitch_bends):
# def add_quantized_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_chord_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_control_steps_to_sequence(sequence, quantized_steps):
#   def __init__(self, num_classes, num_steps=None):
#   def num_classes(self):
#   def default_event(self):
#   def encode_event(self, event):
#   def decode_event(self, index):
#   def event_to_num_steps(self, event):
# def parse_test_proto(proto_type, proto_string):
# def get_testdata_dir():
#   def setUp(self):
#   def _AssertProtoEquals(self, a, b, msg=None):  # pylint:disable=invalid-name
#   def assertProtoEquals(self, expected_message_maybe_ascii, message, msg=None):
# class TrivialOneHotEncoding(encoder_decoder.OneHotEncoding):
# class ProtoTestCase(absltest.TestCase):


# Path: note_seq/melody_inference_test.py
from absl.testing import absltest
from note_seq import melody_inference
from note_seq import testing_lib
from note_seq.protobuf import music_pb2

        sequence, 0,
        [(60, 100, 0.5, 2.0), (62, 100, 1.0, 1.25)])

    pitches, has_onsets, has_notes, event_times = (
        melody_inference.sequence_note_frames(sequence))

    expected_pitches = [60, 62]
    expected_has_onsets = [[0, 0], [1, 0], [0, 1], [0, 0]]
    expected_has_notes = [[0, 0], [1, 0], [1, 1], [1, 0]]
    expected_event_times = [0.5, 1.0, 1.25]

    self.assertEqual(expected_pitches, pitches)
    self.assertEqual(expected_has_onsets, has_onsets.tolist())
    self.assertEqual(expected_has_notes, has_notes.tolist())
    self.assertEqual(expected_event_times, event_times)

  def testMelodyInferenceEmptySequence(self):
    sequence = music_pb2.NoteSequence()
    melody_inference.infer_melody_for_sequence(sequence)
    expected_sequence = music_pb2.NoteSequence()
    self.assertEqual(expected_sequence, sequence)

  def testMelodyInferenceSingleNote(self):
    sequence = music_pb2.NoteSequence()
    testing_lib.add_track_to_sequence(
        sequence, 0, [(60, 100, 0.5, 1.0)])

    melody_inference.infer_melody_for_sequence(sequence)

    expected_sequence = music_pb2.NoteSequence()

    testing_lib.add_track_to_sequence(