# Path: moonlight/evaluation/musicxml.py
# OVERALL_SCORE = 'overall_score'
# def musicxml_similarity(a, b):
# def _not_similar():
# def _index(num_staves, num_measures):
#   def __init__(self, score):
#       def num_staves(part):
#   def get_measure(self, part_staff, measure_num):
#   def _build_attributes(self, staff_num, orig_measure):
#     def find_divisions():
#   def num_partstaves(self):
#   def num_measures(self, part_staff):
#   def _get_part(self, part_num):
#   def all_measure_counts(self):
# def _filter_for_staff(staff_num, elem):
# def measure_similarity(a, b):
# def measure_to_note_list(measure):
# def pitch_to_int(pitch):
# def duration_to_fraction(duration, measure):
# def _note_distance(n1, n2):
# def levenshtein(s1, s2, distance=_note_distance):
# def exact_match_distance(n1, n2):
# class PartStaves(object):


import copy
import os.path
import pandas as pd
import pandas.util.testing as pd_testing
import six
from absl.testing import absltest
from lxml import etree
from moonlight.evaluation import musicxml
from six import moves
from tensorflow.python.platform import resource_loader
    # Score 3 should be less similar than 2 to 1
    self.assertLess(similarity13['overall_score']['total'][0],
                    similarity12['overall_score']['total'][0])

  def testLevenshteinDistance(self):

    def levenshtein(a, b):
      return musicxml.levenshtein(a, b, musicxml.exact_match_distance)

    self.assertEqual(levenshtein('sky', 'sky'), 0)
    self.assertEqual(levenshtein('sky', 'soy'), 1)
    self.assertEqual(levenshtein('sky', 'skyll'), 2)
    self.assertEqual(levenshtein('sky', 's'), 2)
    self.assertEqual(levenshtein('sky', 'dig'), 3)
    self.assertEqual(levenshtein([(1, 2), (3, 4)], [(1, 2), (4, 3)]), 1)
    self.assertEqual(
        levenshtein([(1), (2), (3, (1, 2))], [(1, 2), (2), (3, (1, 3))]), 2)

  def testOptionalAlter(self):
    pitch = etree.Element('pitch')
    etree.SubElement(pitch, 'step').text = 'C'
    etree.SubElement(pitch, 'octave').text = '4'

    pitch_with_alter = copy.deepcopy(pitch)
    etree.SubElement(pitch_with_alter, 'alter').text = '0'
    self.assertEqual(
        musicxml.pitch_to_int(pitch), musicxml.pitch_to_int(pitch_with_alter))

    pitch_with_alter.find('alter').text = '-1'
    self.assertNotEqual(

# Path: moonlight/evaluation/musicxml.py
# OVERALL_SCORE = 'overall_score'
# def musicxml_similarity(a, b):
# def _not_similar():
# def _index(num_staves, num_measures):
#   def __init__(self, score):
#       def num_staves(part):
#   def get_measure(self, part_staff, measure_num):
#   def _build_attributes(self, staff_num, orig_measure):
#     def find_divisions():
#   def num_partstaves(self):
#   def num_measures(self, part_staff):
#   def _get_part(self, part_num):
#   def all_measure_counts(self):
# def _filter_for_staff(staff_num, elem):
# def measure_similarity(a, b):
# def measure_to_note_list(measure):
# def pitch_to_int(pitch):
# def duration_to_fraction(duration, measure):
# def _note_distance(n1, n2):
# def levenshtein(s1, s2, distance=_note_distance):
# def exact_match_distance(n1, n2):
# class PartStaves(object):


# Path: moonlight/evaluation/musicxml_test.py
import copy
import os.path
import pandas as pd
import pandas.util.testing as pd_testing
import six
from absl.testing import absltest
from lxml import etree
from moonlight.evaluation import musicxml
from six import moves
from tensorflow.python.platform import resource_loader

    # Score 3 should be less similar than 2 to 1
    self.assertLess(similarity13['overall_score']['total'][0],
                    similarity12['overall_score']['total'][0])

  def testLevenshteinDistance(self):

    def levenshtein(a, b):
      return musicxml.levenshtein(a, b, musicxml.exact_match_distance)

    self.assertEqual(levenshtein('sky', 'sky'), 0)
    self.assertEqual(levenshtein('sky', 'soy'), 1)
    self.assertEqual(levenshtein('sky', 'skyll'), 2)
    self.assertEqual(levenshtein('sky', 's'), 2)
    self.assertEqual(levenshtein('sky', 'dig'), 3)
    self.assertEqual(levenshtein([(1, 2), (3, 4)], [(1, 2), (4, 3)]), 1)
    self.assertEqual(
        levenshtein([(1), (2), (3, (1, 2))], [(1, 2), (2), (3, (1, 3))]), 2)

  def testOptionalAlter(self):
    pitch = etree.Element('pitch')
    etree.SubElement(pitch, 'step').text = 'C'
    etree.SubElement(pitch, 'octave').text = '4'

    pitch_with_alter = copy.deepcopy(pitch)
    etree.SubElement(pitch_with_alter, 'alter').text = '0'
    self.assertEqual(
        musicxml.pitch_to_int(pitch), musicxml.pitch_to_int(pitch_with_alter))

    pitch_with_alter.find('alter').text = '-1'
    self.assertNotEqual(

        musicxml.pitch_to_int(pitch), musicxml.pitch_to_int(pitch_with_alter))