class_docstr: Fake test used to compare directories of abc and midi files.
class_docstr_tok: ["Fake","test","used","to","compare","directories","of","abc","and","midi","files","."]
code: def compare_directory(self, directory):
      self.maxDiff = None  # pylint: disable=invalid-name
  
      files_in_dir = tf.gfile.ListDirectory(directory)
      files_parsed = 0
      for file_in_dir in files_in_dir:
          if not file_in_dir.endswith(".abc"):
              continue
          abc = os.path.join(directory, file_in_dir)
          midis = {}
          ref_num = 1
          while True:
              midi = re.sub(
                  r"\.abc$",
                  str(ref_num) + ".mid",
                  os.path.join(directory, file_in_dir),
              )
              if not tf.gfile.Exists(midi):
                  break
              midis[ref_num] = midi
              ref_num += 1
  
          print("parsing {}: {}".format(files_parsed, abc))
          tunes, exceptions = abc_parser.parse_abc_tunebook_file(abc)
          files_parsed += 1
          self.assertEqual(len(tunes), len(midis) - len(exceptions))
  
          for tune in tunes.values():
              expanded_tune = sequences_lib.expand_section_groups(tune)
              midi_ns = midi_io.midi_file_to_sequence_proto(
                  midis[tune.reference_number]
              )
              # abc2midi adds a 1-tick delay to the start of every note, but we don't.
              tick_length = (
                  1 / (midi_ns.tempos[0].qpm / 60)
              ) / midi_ns.ticks_per_quarter
              for note in midi_ns.notes:
                  note.start_time -= tick_length
                  # For now, don't compare velocities.
                  note.velocity = 90
              if len(midi_ns.notes) != len(expanded_tune.notes):
                  pdb.set_trace()
                  self.assertProtoEquals(midi_ns, expanded_tune)
              for midi_note, test_note in zip(
                  midi_ns.notes, expanded_tune.notes
              ):
                  try:
                      self.assertProtoEquals(midi_note, test_note)
                  except Exception as e:  # pylint: disable=broad-except
                      print(e)
                      pdb.set_trace()
              self.assertEqual(
                  midi_ns.total_time, expanded_tune.total_time
              )
  
file_path: magenta/magenta/scripts/abc_compare.py
imports: import os
  import pdb
  import re
  from note_seq import abc_parser
  from note_seq import midi_io
  from note_seq import sequences_lib
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the CompareDirectory obj's underlying member method code with example usage: obj.compare_directory(directory) without return types