def test_generate_note(self):
        """Tests that `generate_note` returns a valid note.

        Executes `generate_note` multiple times with varying paramters.
        """

        # For parameters to `generate_note`, we use all permutations of length
        # three of the notes in `test_notes`.
        for args in itertools.permutations(self.test_notes, 3):
            note = generation.generate_note(args[0], args[1],
                                            [(args[2] % 12), 1])
            assert note in self.valid_notes, "%d is not a valid note" % (note)
Exemple #2
0
 def rand(cls, num_tatums):
     """Generates a random individual."""
     obj = cls([], [])
     obj.notes = [[] for i in range(num_tatums)]
     n = n0 = notes.Note(0, random.randint(40, 80), 1)
     obj.notes[0].append(n0)
     for i in range(1, num_tatums):
         n = notes.Note(
             0, generation.generate_note(
                 n.midi_note, n0.midi_note, (n0.midi_note, 1)), 1)
         obj.notes[i].append(n)
     return obj