# Path: moonlight/glyphs/base.py
# class GlyphsTensorColumns(enum.IntEnum):
# class BaseGlyphClassifier(object):
#   STAFF_INDEX = 0
#   Y_POSITION = 1
#   X = 2
#   TYPE = 3
#   def __init__(self):
#   def get_detected_glyphs(self):
#   def glyph_predictions_to_page(self, predictions):
#     def create_glyph(glyph):
#     def generate_staff(staff_num):
# 
# Path: moonlight/glyphs/convolutional.py
# DEFAULT_RUN_MIN_LENGTH = 3
# class Convolutional1DGlyphClassifier(base.BaseGlyphClassifier):
#   def __init__(self, run_min_length=DEFAULT_RUN_MIN_LENGTH):
#   def staffline_predictions(self):
#   def _build_detected_glyphs(self, predictions_arr):
#   def _create_glyph_arr(self, staff_index, y_position, x, type_value):
#   def get_detected_glyphs(self):
# 
# Path: moonlight/glyphs/testing.py
# PREDICTIONS = np.asarray(
#     [[[1, 1, 1, 1, 2, 1],
#       [3, 1, 5, 1, 1, 1],
#       [1, 4, 1, 1, 1, 1]],
#      [[1, 1, 3, 1, 1, 1],
#       [1, 1, 5, 1, 1, 1],
#       [1, 1, 1, 1, 3, 5]]])  # pyformat: disable
# GLYPHS_PAGE = musicscore_pb2.Page(system=[
#     musicscore_pb2.StaffSystem(staff=[
#         musicscore_pb2.Staff(glyph=[
#             musicscore_pb2.Glyph(x=0, y_position=0, type=3),
#             musicscore_pb2.Glyph(x=1, y_position=-1, type=4),
#             musicscore_pb2.Glyph(x=2, y_position=0, type=5),
#             musicscore_pb2.Glyph(x=4, y_position=1, type=2),
#         ]),
#         musicscore_pb2.Staff(glyph=[
#             musicscore_pb2.Glyph(x=2, y_position=1, type=3),
#             musicscore_pb2.Glyph(x=2, y_position=0, type=5),
#             musicscore_pb2.Glyph(x=4, y_position=-1, type=3),
#             musicscore_pb2.Glyph(x=5, y_position=-1, type=5),
#         ]),
#     ]),
# ])
# class DummyGlyphClassifier(convolutional.Convolutional1DGlyphClassifier):
#   def __init__(self, predictions):
#   def staffline_predictions(self):


import numpy as np
import pandas as pd
import tensorflow as tf
from moonlight.glyphs import base
from moonlight.glyphs import convolutional
from moonlight.glyphs import testing
from moonlight.protobuf import musicscore_pb2

class ConvolutionalTest(tf.test.TestCase):

  def testGetGlyphsPage(self):
    # Refer to testing.py for the glyphs array.
    # pyformat: disable
    glyphs = pd.DataFrame(
        [
            {STAFF_INDEX: 0, Y_POSITION: 0, X: 0, TYPE: 3},
            {STAFF_INDEX: 0, Y_POSITION: -1, X: 1, TYPE: 4},
            {STAFF_INDEX: 0, Y_POSITION: 0, X: 2, TYPE: 5},
            {STAFF_INDEX: 0, Y_POSITION: 1, X: 4, TYPE: 2},
            {STAFF_INDEX: 1, Y_POSITION: 1, X: 2, TYPE: 3},
            {STAFF_INDEX: 1, Y_POSITION: 0, X: 2, TYPE: 5},
            {STAFF_INDEX: 1, Y_POSITION: -1, X: 4, TYPE: 3},
            {STAFF_INDEX: 1, Y_POSITION: -1, X: 5, TYPE: 5},
        ],
        columns=[STAFF_INDEX, Y_POSITION, X, TYPE])
    # Compare glyphs (rows in the glyphs array) regardless of their position in
    # the array (they are not required to be sorted).
    self.assertEqual(
        set(
            map(tuple,
                convolutional.Convolutional1DGlyphClassifier(
                    run_min_length=1)._build_detected_glyphs(
                        testing.PREDICTIONS))),
        set(map(tuple, glyphs.values)))

  def testNoGlyphs_dummyClassifier(self):


# Path: moonlight/glyphs/base.py
# class GlyphsTensorColumns(enum.IntEnum):
# class BaseGlyphClassifier(object):
#   STAFF_INDEX = 0
#   Y_POSITION = 1
#   X = 2
#   TYPE = 3
#   def __init__(self):
#   def get_detected_glyphs(self):
#   def glyph_predictions_to_page(self, predictions):
#     def create_glyph(glyph):
#     def generate_staff(staff_num):
# 
# Path: moonlight/glyphs/convolutional.py
# DEFAULT_RUN_MIN_LENGTH = 3
# class Convolutional1DGlyphClassifier(base.BaseGlyphClassifier):
#   def __init__(self, run_min_length=DEFAULT_RUN_MIN_LENGTH):
#   def staffline_predictions(self):
#   def _build_detected_glyphs(self, predictions_arr):
#   def _create_glyph_arr(self, staff_index, y_position, x, type_value):
#   def get_detected_glyphs(self):
# 
# Path: moonlight/glyphs/testing.py
# PREDICTIONS = np.asarray(
#     [[[1, 1, 1, 1, 2, 1],
#       [3, 1, 5, 1, 1, 1],
#       [1, 4, 1, 1, 1, 1]],
#      [[1, 1, 3, 1, 1, 1],
#       [1, 1, 5, 1, 1, 1],
#       [1, 1, 1, 1, 3, 5]]])  # pyformat: disable
# GLYPHS_PAGE = musicscore_pb2.Page(system=[
#     musicscore_pb2.StaffSystem(staff=[
#         musicscore_pb2.Staff(glyph=[
#             musicscore_pb2.Glyph(x=0, y_position=0, type=3),
#             musicscore_pb2.Glyph(x=1, y_position=-1, type=4),
#             musicscore_pb2.Glyph(x=2, y_position=0, type=5),
#             musicscore_pb2.Glyph(x=4, y_position=1, type=2),
#         ]),
#         musicscore_pb2.Staff(glyph=[
#             musicscore_pb2.Glyph(x=2, y_position=1, type=3),
#             musicscore_pb2.Glyph(x=2, y_position=0, type=5),
#             musicscore_pb2.Glyph(x=4, y_position=-1, type=3),
#             musicscore_pb2.Glyph(x=5, y_position=-1, type=5),
#         ]),
#     ]),
# ])
# class DummyGlyphClassifier(convolutional.Convolutional1DGlyphClassifier):
#   def __init__(self, predictions):
#   def staffline_predictions(self):


# Path: moonlight/glyphs/convolutional_test.py
import numpy as np
import pandas as pd
import tensorflow as tf
from moonlight.glyphs import base
from moonlight.glyphs import convolutional
from moonlight.glyphs import testing
from moonlight.protobuf import musicscore_pb2


class ConvolutionalTest(tf.test.TestCase):

  def testGetGlyphsPage(self):
    # Refer to testing.py for the glyphs array.
    # pyformat: disable
    glyphs = pd.DataFrame(
        [
            {STAFF_INDEX: 0, Y_POSITION: 0, X: 0, TYPE: 3},
            {STAFF_INDEX: 0, Y_POSITION: -1, X: 1, TYPE: 4},
            {STAFF_INDEX: 0, Y_POSITION: 0, X: 2, TYPE: 5},
            {STAFF_INDEX: 0, Y_POSITION: 1, X: 4, TYPE: 2},
            {STAFF_INDEX: 1, Y_POSITION: 1, X: 2, TYPE: 3},
            {STAFF_INDEX: 1, Y_POSITION: 0, X: 2, TYPE: 5},
            {STAFF_INDEX: 1, Y_POSITION: -1, X: 4, TYPE: 3},
            {STAFF_INDEX: 1, Y_POSITION: -1, X: 5, TYPE: 5},
        ],
        columns=[STAFF_INDEX, Y_POSITION, X, TYPE])
    # Compare glyphs (rows in the glyphs array) regardless of their position in
    # the array (they are not required to be sorted).
    self.assertEqual(
        set(
            map(tuple,
                convolutional.Convolutional1DGlyphClassifier(
                    run_min_length=1)._build_detected_glyphs(
                        testing.PREDICTIONS))),
        set(map(tuple, glyphs.values)))

  def testNoGlyphs_dummyClassifier(self):


    class DummyClassifier(convolutional.Convolutional1DGlyphClassifier):