def test_sparse_pianoroll_to_dense_subtracts_min_note(self): sparse_pianoroll = [(4, 5), (5, 4), (), (5, ), (), ()] dense_pianoroll, num_timesteps = datasets.sparse_pianoroll_to_dense( sparse_pianoroll, min_note=4, num_notes=2) self.assertEqual(num_timesteps, 6) self.assertAllEqual([[1, 1], [1, 1], [0, 0], [0, 1], [0, 0], [0, 0]], dense_pianoroll)
def test_sparse_pianoroll_to_dense_empty_at_end(self): sparse_pianoroll = [(0, 1), (1, 0), (), (1, ), (), ()] dense_pianoroll, num_timesteps = datasets.sparse_pianoroll_to_dense( sparse_pianoroll, min_note=0, num_notes=2) self.assertEqual(num_timesteps, 6) self.assertAllEqual([[1, 1], [1, 1], [0, 0], [0, 1], [0, 0], [0, 0]], dense_pianoroll)
def test_sparse_pianoroll_to_dense_simple(self): sparse_pianoroll = [(0,), (), (1,)] dense_pianoroll, num_timesteps = datasets.sparse_pianoroll_to_dense( sparse_pianoroll, min_note=0, num_notes=2) self.assertEqual(num_timesteps, 3) self.assertAllEqual([[1, 0], [0, 0], [0, 1]], dense_pianoroll)
def test_sparse_pianoroll_to_dense_uses_num_notes(self): sparse_pianoroll = [(4, 5), (5, 4), (), (5,), (), ()] dense_pianoroll, num_timesteps = datasets.sparse_pianoroll_to_dense( sparse_pianoroll, min_note=4, num_notes=3) self.assertEqual(num_timesteps, 6) self.assertAllEqual([[1, 1, 0], [1, 1, 0], [0, 0, 0], [0, 1, 0], [0, 0, 0], [0, 0, 0]], dense_pianoroll)
def test_sparse_pianoroll_to_dense_empty_at_end(self): sparse_pianoroll = [(0, 1), (1, 0), (), (1,), (), ()] dense_pianoroll, num_timesteps = datasets.sparse_pianoroll_to_dense( sparse_pianoroll, min_note=0, num_notes=2) self.assertEqual(num_timesteps, 6) self.assertAllEqual([[1, 1], [1, 1], [0, 0], [0, 1], [0, 0], [0, 0]], dense_pianoroll)