Exemple #1
0
 def setUp(self):
     """Set up stuff"""
     self.pathnames = ['test_path_1', 'test_path_2', 'test_path_3']
     self.ind_pieces = [MagicMock(spec=IndexedPiece) for _ in range(len(self.pathnames))]
     for i, ind_p in enumerate(self.ind_pieces):
         ind_p.metadata.return_value = self.pathnames[i]
     self.agg_p = AggregatedPieces(pieces=self.ind_pieces)
     self.agg_p2 = AggregatedPieces(pieces=[IndexedPiece(path) for path in self.pathnames])
Exemple #2
0
 def test_get_data_2(self):
     """try get_data() on an AggregatedPieces object with no pieces"""
     aps = AggregatedPieces()
     self.assertRaises(RuntimeWarning, aps.get_data, None, None)
     try:
         aps.get_data()
     except RuntimeWarning as r_warn:
         # pylint: disable=protected-access
         self.assertEqual(AggregatedPieces._NO_PIECES, r_warn.args[0])
Exemple #3
0
 def test_get_data_3(self):
     """integration test with a nested called to get_data, an ind_analyzer and a 
     combined_experimenter"""
     expected = pandas.Series([4.0,2.0,2.0,2.0,2.0,2.0,2.0,4.0],
                              index=['C3','C4','D4','E4','F4','G2','G4','Rest'])
     pieces = [Importer(os.path.join(VIS_PATH, 'tests', 'corpus', 'test_fermata_rest.xml'))]*2
     aps = AggregatedPieces(pieces=pieces)
     actual = aps.get_data(combined_experimenter='aggregator',
                           data=aps.get_data(ind_analyzer='noterest', combined_experimenter='frequency'))
     self.assertTrue(actual.iloc[:,0].equals(expected))
 def test_get_data_3(self):
     # try get_data() on an AggregatedPieces with no pieces (with aggregated analyzers)
     mock_indexer_cls = type('MockIndexer', (Indexer,), {})
     mock_experimenter_cls = type('MockExperimenter', (Experimenter,), {})
     expected = pandas.DataFrame()
     aps = AggregatedPieces()
     actual = aps.get_data([mock_experimenter_cls], [mock_indexer_cls])
     self.assertSequenceEqual(list(expected.index), list(actual.index))
     self.assertSequenceEqual(list(expected.columns), list(actual.columns))
     self.assertSequenceEqual(list(expected), list(actual))
 def test_get_data_2(self):
     # try get_data() on an AggregatedPieces with no pieces (no aggregated analyzers)
     mock_indexer_cls = type('MockIndexer', (Indexer,), {})
     expected = [pandas.DataFrame()]
     aps = AggregatedPieces()
     actual = aps.get_data([], [mock_indexer_cls])
     self.assertEqual(len(expected), len(actual))
     self.assertSequenceEqual(list(expected[0].index), list(actual[0].index))
     self.assertSequenceEqual(list(expected[0].columns), list(actual[0].columns))
     self.assertSequenceEqual(list(expected[0]), list(actual[0]))
def Importer(location, metafile=None):
    """
    Import the file, website link, or directory of files designated by ``location`` to music21 
    format.

    :param location: Location of the file to import on the local disk.
    :type location: str
    :returns: An :class:`IndexedPiece` or an :class:`AggregatedPieces` object if the file passed 
        imports as a :class:`music21.stream.Score` or :class:`music21.stream.Opus` object
        respectively.
    :rtype: A new :class:`IndexedPiece` or :class:`AggregatedPieces` object.
    """
    pieces = []

    # load directory of pieces
    if isinstance(location, list) or os.path.isdir(location):
        directory_return = _import_directory(location, metafile)
        pieces.extend(directory_return[0])
        metafile = directory_return[1]

    # index piece if it is a file or a link
    elif os.path.isfile(location):
        pieces.extend(_import_file(location))

    else:
        raise RuntimeError(_UNKNOWN_INPUT)

    if len(pieces) == 1: # there was a single piece that imported as a score (not an opus)
        return(pieces[0]) # this returns an IndexedPiece object
    else: # there were multiple pieces or a single piece that imported as an opus
        return(AggregatedPieces(pieces=pieces, metafile=metafile))
Exemple #7
0
    def _run_freq_agg(self):
        """
        Run the frequency and aggregation experimenters:

        * :class:`~vis.analyzers.experimenters.frequencyFrequencyExperimenter`
        * :class:`~vis.analyzers.experimenters.aggregator.ColumnAggregator`

        Use this method from other :class:`WorkflowManager` methods for counting frequency.

        .. note:: This method runs on, then overwrites, values stored in :attr:`self._result`.

        :returns: Aggregated frequency counts for everything stored in :attr:`self._result`.
        :rtype: :class:`pandas.Series`
        """
        # NB: there's no "logic" here, so I didn't bother testing the method
        agg_p = AggregatedPieces(self._data)
        self._result = agg_p.get_data([aggregator.ColumnAggregator],
                                      [frequency.FrequencyExperimenter],
                                      {},
                                      self._result)
        self._result.sort(ascending=False)
        return self._result
Exemple #8
0
class TestAggregatedPieces(TestCase):
    """Tests for AggregatedPieces"""
    # pylint: disable=too-many-public-methods

    def setUp(self):
        """Set up stuff"""
        self.pathnames = ['test_path_1', 'test_path_2', 'test_path_3']
        self.ind_pieces = [MagicMock(spec=IndexedPiece) for _ in range(len(self.pathnames))]
        for i, ind_p in enumerate(self.ind_pieces):
            ind_p.metadata.return_value = self.pathnames[i]
        self.agg_p = AggregatedPieces(pieces=self.ind_pieces)
        self.agg_p2 = AggregatedPieces(pieces=[IndexedPiece(path) for path in self.pathnames])

    def test_metadata_1(self):
        """access the field automatically set"""
        self.assertSequenceEqual(self.pathnames, self.agg_p2.metadata('pathnames'))

    def test_metadata_2(self):
        """raises TypeError if the field is not a string"""
        self.assertRaises(TypeError, self.agg_p.metadata, 12)
        try:
            self.agg_p.metadata(12)
        except TypeError as t_err:
            self.assertEqual(AggregatedPieces._FIELD_STRING, t_err.args[0])  # pylint: disable=protected-access

    def test_metadata_3(self):
        """returns None for non-existant field"""
        self.assertEqual(None, self.agg_p.metadata('pizza value'))

    def test_metadata_4(self):
        """calls _fetch_metadata() a not-yet-initialized field"""
        # pylint: disable=W0212
        self.agg_p._fetch_metadata = MagicMock(return_value=['Composer list!'])
        self.assertEqual(['Composer list!'], self.agg_p.metadata('composers'))
        self.agg_p._fetch_metadata.assert_called_once_with('composers')

    def test_fetch_metadata_1(self):
        """composers field"""
        self.ind_pieces[0].metadata = MagicMock(return_value='Bok')
        self.ind_pieces[1].metadata = MagicMock(return_value='Baytowvinn')
        self.ind_pieces[2].metadata = MagicMock(return_value='The Boys')
        expected = ['Bok', 'Baytowvinn', 'The Boys']
        self.assertEqual(expected, self.agg_p._fetch_metadata('composers'))  # pylint: disable=protected-access
        self.assertEqual(expected, self.agg_p._metadata['composers'])  # pylint: disable=protected-access
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with('composer')

    def test_fetch_metadata_2a(self):
        """dates field"""
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value='1993')
        self.ind_pieces[1].metadata = MagicMock(return_value='1302')
        self.ind_pieces[2].metadata = MagicMock(return_value='1987')
        expected = ['1993', '1302', '1987']
        self.assertSequenceEqual(expected, self.agg_p._fetch_metadata('dates'))  # pylint: disable=protected-access
        self.assertSequenceEqual(expected, self.agg_p._metadata['dates'])  # pylint: disable=protected-access
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with('date')

    def test_fetch_metadata_2b(self):
        """dates field with ranges"""
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value='1993 to 1993/08/08')
        self.ind_pieces[1].metadata = MagicMock(return_value='1302 to 1405')
        # he predicted his own death date in a unit test
        self.ind_pieces[2].metadata = MagicMock(return_value='1987/09/09 to 2045/05/12')
        expected = ['1993 to 1993/08/08', '1302 to 1405', '1987/09/09 to 2045/05/12']
        self.assertSequenceEqual(expected, self.agg_p._fetch_metadata('dates'))  # pylint: disable=protected-access
        self.assertSequenceEqual(expected, self.agg_p._metadata['dates'])  # pylint: disable=protected-access
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with('date')

    def test_fetch_metadata_3(self):
        """date range field"""
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value='1993')
        self.ind_pieces[1].metadata = MagicMock(return_value='1302')
        self.ind_pieces[2].metadata = MagicMock(return_value='1987')
        expected = ('1302', '1993')
        self.assertSequenceEqual(expected, self.agg_p._fetch_metadata('date_range'))  # pylint: disable=protected-access
        self.assertSequenceEqual(expected, self.agg_p._metadata['date_range'])  # pylint: disable=protected-access
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with('date')

    def test_fetch_metadata_4(self):
        """titles field"""
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value='Boris Godunov')
        self.ind_pieces[1].metadata = MagicMock(return_value='Peter Grimes')
        self.ind_pieces[2].metadata = MagicMock(return_value='Lights and Music')
        expected = ['Boris Godunov', 'Peter Grimes', 'Lights and Music']
        self.assertEqual(expected, self.agg_p._fetch_metadata('titles'))  # pylint: disable=protected-access
        self.assertEqual(expected, self.agg_p._metadata['titles'])  # pylint: disable=protected-access
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with('title')

    def test_fetch_metadata_5(self):
        """locales field"""
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value='Cheronnow')
        self.ind_pieces[1].metadata = MagicMock(return_value='Munchreeawl')
        self.ind_pieces[2].metadata = MagicMock(return_value='Cowgree')
        expected = ['Cheronnow', 'Munchreeawl', 'Cowgree']
        self.assertEqual(expected, self.agg_p._fetch_metadata('locales'))  # pylint: disable=protected-access
        self.assertEqual(expected, self.agg_p._metadata['locales'])  # pylint: disable=protected-access
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with('locale_of_composition')

    def test_get_data_1(self):
        """try getting data for a non-Indexer, non-Experimenter class"""
        self.assertRaises(TypeError, self.agg_p.get_data, None, '')
        try:
            self.agg_p.get_data(None, '')
        except TypeError as t_err:
            # pylint: disable=protected-access
            self.assertEqual(AggregatedPieces._NOT_EXPERIMENTER.format('', sorted([k[0] for k in self.agg_p._mkd.keys()])),
                             t_err.args[0])

    def test_get_data_2(self):
        """try get_data() on an AggregatedPieces object with no pieces"""
        aps = AggregatedPieces()
        self.assertRaises(RuntimeWarning, aps.get_data, None, None)
        try:
            aps.get_data()
        except RuntimeWarning as r_warn:
            # pylint: disable=protected-access
            self.assertEqual(AggregatedPieces._NO_PIECES, r_warn.args[0])

    def test_get_data_3(self):
        """integration test with a nested called to get_data, an ind_analyzer and a 
        combined_experimenter"""
        expected = pandas.Series([4.0,2.0,2.0,2.0,2.0,2.0,2.0,4.0],
                                 index=['C3','C4','D4','E4','F4','G2','G4','Rest'])
        pieces = [Importer(os.path.join(VIS_PATH, 'tests', 'corpus', 'test_fermata_rest.xml'))]*2
        aps = AggregatedPieces(pieces=pieces)
        actual = aps.get_data(combined_experimenter='aggregator',
                              data=aps.get_data(ind_analyzer='noterest', combined_experimenter='frequency'))
        self.assertTrue(actual.iloc[:,0].equals(expected))

    def test_date(self):
        date = ['----/--/-- to ----/--/--']
        agg = AggregatedPieces()._make_date_range(date)
        self.assertEqual(agg, None)
Exemple #9
0
 def test_date(self):
     date = ['----/--/-- to ----/--/--']
     agg = AggregatedPieces()._make_date_range(date)
     self.assertEqual(agg, None)
 def setUp(self):
     self.pathnames = [u'test_path_1', u'test_path_2', u'test_path_3']
     self.ind_pieces = [MagicMock(spec=IndexedPiece) for _ in xrange(len(self.pathnames))]
     for i, ind_p in enumerate(self.ind_pieces):
         ind_p.metadata.return_value = self.pathnames[i]
     self.agg_p = AggregatedPieces(self.ind_pieces)
class TestAggregatedPieces(TestCase):
    def setUp(self):
        self.pathnames = [u'test_path_1', u'test_path_2', u'test_path_3']
        self.ind_pieces = [MagicMock(spec=IndexedPiece) for _ in xrange(len(self.pathnames))]
        for i, ind_p in enumerate(self.ind_pieces):
            ind_p.metadata.return_value = self.pathnames[i]
        self.agg_p = AggregatedPieces(self.ind_pieces)

    def test_metadata_1(self):
        # access the field automatically set
        self.assertSequenceEqual(self.pathnames, self.agg_p.metadata(u'pathnames'))

    def test_metadata_2(self):
        # raises TypeError if the field is not a basestring
        self.assertRaises(TypeError, self.agg_p.metadata, 12)

    def test_metadata_3(self):
        # returns None for non-existant field
        self.assertEqual(None, self.agg_p.metadata(u'pizza value'))

    def test_metadata_4(self):
        # calls _fetch_metadata() a not-yet-initialized field
        # pylint: disable=W0212
        self.agg_p._fetch_metadata = MagicMock(return_value=[u'Composer list!'])
        self.assertEqual([u'Composer list!'], self.agg_p.metadata(u'composers'))
        self.agg_p._fetch_metadata.assert_called_once_with(u'composers')

    def test_fetch_metadata_1(self):
        # composers field
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value = u'Bok')
        self.ind_pieces[1].metadata = MagicMock(return_value = u'Baytowvinn')
        self.ind_pieces[2].metadata = MagicMock(return_value = u'The Boys')
        expected = [u'Bok', u'Baytowvinn', u'The Boys']
        self.assertEqual(expected, self.agg_p._fetch_metadata(u'composers'))
        self.assertEqual(expected, self.agg_p._metadata['composers'])  # pylint: disable=E1101
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with(u'composer')

    def test_fetch_metadata_2a(self):
        # dates field
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value = u'1993')
        self.ind_pieces[1].metadata = MagicMock(return_value = u'1302')
        self.ind_pieces[2].metadata = MagicMock(return_value = u'1987')
        expected = [u'1993', u'1302', u'1987']
        self.assertSequenceEqual(expected, self.agg_p._fetch_metadata(u'dates'))
        self.assertSequenceEqual(expected, self.agg_p._metadata[u'dates'])  # pylint: disable=E1101
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with(u'date')

    def test_fetch_metadata_2b(self):
        # dates field with ranges
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value = u'1993 to 1993/08/08')
        self.ind_pieces[1].metadata = MagicMock(return_value = u'1302 to 1405')
        # he predicted his own death date in a unit test
        self.ind_pieces[2].metadata = MagicMock(return_value = u'1987/09/09 to 2045/05/12')
        expected = [u'1993 to 1993/08/08', u'1302 to 1405', u'1987/09/09 to 2045/05/12']
        self.assertSequenceEqual(expected, self.agg_p._fetch_metadata(u'dates'))
        self.assertSequenceEqual(expected, self.agg_p._metadata[u'dates'])  # pylint: disable=E1101
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with(u'date')

    def test_fetch_metadata_3(self):
        # date range field
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value = u'1993')
        self.ind_pieces[1].metadata = MagicMock(return_value = u'1302')
        self.ind_pieces[2].metadata = MagicMock(return_value = u'1987')
        expected = (u'1302', u'1993')
        self.assertSequenceEqual(expected, self.agg_p._fetch_metadata(u'date_range'))
        self.assertSequenceEqual(expected, self.agg_p._metadata[u'date_range'])  # pylint: disable=E1101
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with(u'date')

    def test_fetch_metadata_4(self):
        # titles field
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value = u'Boris Godunov')
        self.ind_pieces[1].metadata = MagicMock(return_value = u'Peter Grimes')
        self.ind_pieces[2].metadata = MagicMock(return_value = u'Lights and Music')
        expected = [u'Boris Godunov', u'Peter Grimes', u'Lights and Music']
        self.assertEqual(expected, self.agg_p._fetch_metadata(u'titles'))
        self.assertEqual(expected, self.agg_p._metadata[u'titles'])  # pylint: disable=E1101
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with(u'title')

    def test_fetch_metadata_5(self):
        # locales field
        # pylint: disable=W0212
        self.ind_pieces[0].metadata = MagicMock(return_value = u'Cheronnow')
        self.ind_pieces[1].metadata = MagicMock(return_value = u'Munchreeawl')
        self.ind_pieces[2].metadata = MagicMock(return_value = u'Cowgree')
        expected = [u'Cheronnow', u'Munchreeawl', u'Cowgree']
        self.assertEqual(expected, self.agg_p._fetch_metadata(u'locales'))
        self.assertEqual(expected, self.agg_p._metadata[u'locales'])  # pylint: disable=E1101
        for piece in self.ind_pieces:
            piece.metadata.assert_called_once_with(u'locale_of_composition')

    def test_get_data_1(self):
        # try getting data for a non-Indexer, non-Experimenter class
        non_analyzer = Mock()
        self.assertRaises(TypeError, self.agg_p.get_data, non_analyzer)

    def test_get_data_2(self):
        # try get_data() on an AggregatedPieces with no pieces (no aggregated analyzers)
        mock_indexer_cls = type('MockIndexer', (Indexer,), {})
        expected = [pandas.DataFrame()]
        aps = AggregatedPieces()
        actual = aps.get_data([], [mock_indexer_cls])
        self.assertEqual(len(expected), len(actual))
        self.assertSequenceEqual(list(expected[0].index), list(actual[0].index))
        self.assertSequenceEqual(list(expected[0].columns), list(actual[0].columns))
        self.assertSequenceEqual(list(expected[0]), list(actual[0]))

    def test_get_data_3(self):
        # try get_data() on an AggregatedPieces with no pieces (with aggregated analyzers)
        mock_indexer_cls = type('MockIndexer', (Indexer,), {})
        mock_experimenter_cls = type('MockExperimenter', (Experimenter,), {})
        expected = pandas.DataFrame()
        aps = AggregatedPieces()
        actual = aps.get_data([mock_experimenter_cls], [mock_indexer_cls])
        self.assertSequenceEqual(list(expected.index), list(actual.index))
        self.assertSequenceEqual(list(expected.columns), list(actual.columns))
        self.assertSequenceEqual(list(expected), list(actual))

    def test_get_data_4(self):
        # chained independent indexers, no aggregated results
        for piece in self.ind_pieces:
            piece.get_data.return_value = pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0])
        an_indexer = type('AMockIndexer', (Indexer,), {})
        other_indexer = type('OtherMockIndexer', (Indexer,), {})
        expected = [pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0]) for _ in xrange(3)]
        actual = self.agg_p.get_data([], [an_indexer, other_indexer])
        self.assertEqual(len(expected), len(actual))
        for i in xrange(len(expected)):
            self.assertSequenceEqual(list(expected[i].index), list(actual[i].index))
            self.assertSequenceEqual(list(expected[i]), list(actual[i]))
        for piece in self.ind_pieces:
            piece.get_data.assert_called_once_with([an_indexer, other_indexer], None)

    def test_get_data_5(self):
        # chained independent indexers, one aggregated experimenter
        for piece in self.ind_pieces:
            piece.get_data.return_value = pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0])
        an_indexer = type('AMockIndexer', (Indexer,), {})
        other_indexer = type('OtherMockIndexer', (Indexer,), {})
        an_experimenter = type('AMockExperimenter', (Experimenter,), {})
        an_experimenter.run = MagicMock(return_value = pandas.DataFrame({0: [1, 2], 2: [4, 5]}))
        expected = pandas.DataFrame({0: [1, 2], 2: [4, 5]})
        actual = self.agg_p.get_data([an_experimenter], [an_indexer, other_indexer])
        self.assertSequenceEqual(list(expected.index), list(actual.index))
        self.assertSequenceEqual(list(expected.columns), list(actual.columns))
        self.assertSequenceEqual(list(expected), list(actual))
        for piece in self.ind_pieces:
            piece.get_data.assert_called_once_with([an_indexer, other_indexer], None)
        an_experimenter.run.assert_called_once_with()

    def test_get_data_6(self):
        # chained independent indexers, chained aggregated experimenters
        for piece in self.ind_pieces:
            piece.get_data.return_value = pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0])
        an_indexer = type('AMockIndexer', (Indexer,), {})
        other_indexer = type('OtherMockIndexer', (Indexer,), {})
        an_experimenter = type('AMockExperimenter', (Experimenter,), {})
        an_experimenter.run = MagicMock()
        other_experimenter = type('OtherMockExperimenter', (Experimenter,), {})
        other_experimenter.run = MagicMock(return_value = pandas.DataFrame({0: [1, 2], 2: [4, 5]}))
        expected = pandas.DataFrame({0: [1, 2], 2: [4, 5]})
        actual = self.agg_p.get_data([an_experimenter, other_experimenter],
                                     [an_indexer, other_indexer])
        self.assertSequenceEqual(list(expected.index), list(actual.index))
        self.assertSequenceEqual(list(expected.columns), list(actual.columns))
        self.assertSequenceEqual(list(expected), list(actual))
        for piece in self.ind_pieces:
            piece.get_data.assert_called_once_with([an_indexer, other_indexer], None)
        an_experimenter.run.assert_called_once_with()
        other_experimenter.run.assert_called_once_with()

    def test_get_data_7(self):
        # one independent indexer, no aggregated results... checking settings get sent
        for piece in self.ind_pieces:
            piece.get_data.return_value = pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0])
        an_indexer = type('AMockIndexer', (Indexer,), {})
        expected = [pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0]) for _ in xrange(3)]
        actual = self.agg_p.get_data([], [an_indexer], {u'awesome': True})
        self.assertEqual(len(expected), len(actual))
        for i in xrange(len(expected)):
            self.assertSequenceEqual(list(expected[i].index), list(actual[i].index))
            self.assertSequenceEqual(list(expected[i]), list(actual[i]))
        for piece in self.ind_pieces:
            piece.get_data.assert_called_once_with([an_indexer], {u'awesome': True})

    def test_get_data_8(self):
        # if a class in "aggregated_experiments" isn't an experimenter
        for piece in self.ind_pieces:
            piece.get_data.return_value = pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0])
        an_indexer = type('AMockIndexer', (Indexer,), {})
        self.assertRaises(TypeError, self.agg_p.get_data, [TestAggregatedPieces], [an_indexer],
                          {u'awesome': True})

    def test_get_data_9(self):
        # no independent indexers (given as None), chained aggregated experimenters
        # NB: based on test 6
        for piece in self.ind_pieces:
            piece.get_data.return_value = pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0])
        an_experimenter = type('AMockExperimenter', (Experimenter,), {})
        an_experimenter.__init__ = MagicMock(return_value=None)
        an_experimenter.run = MagicMock()
        an_experimenter.run.return_value = 41
        other_experimenter = type('OtherMockExperimenter', (Experimenter,), {})
        other_experimenter.__init__ = MagicMock(return_value=None)
        other_experimenter.run = MagicMock(return_value = pandas.DataFrame({0: [1, 2], 2: [4, 5]}))
        expected = pandas.DataFrame({0: [1, 2], 2: [4, 5]})
        actual = self.agg_p.get_data([an_experimenter, other_experimenter], None, {}, 14)
        self.assertSequenceEqual(list(expected.index), list(actual.index))
        self.assertSequenceEqual(list(expected.columns), list(actual.columns))
        self.assertSequenceEqual(list(expected), list(actual))
        for piece in self.ind_pieces:
            self.assertEqual(0, piece.get_data.call_count)
        an_experimenter.__init__.assert_called_once_with(14, {})
        an_experimenter.run.assert_called_once_with()
        other_experimenter.__init__.assert_called_once_with(an_experimenter.run.return_value, {})
        other_experimenter.run.assert_called_once_with()

    def test_get_data_10(self):
        # no independent indexers (given as []), chained aggregated experimenters
        # NB: based on test 9
        for piece in self.ind_pieces:
            piece.get_data.return_value = pandas.Series(['c4', 'd4', 'e4'], index=[0.0, 0.5, 1.0])
        an_experimenter = type('AMockExperimenter', (Experimenter,), {})
        an_experimenter.__init__ = MagicMock(return_value=None)
        an_experimenter.run = MagicMock()
        an_experimenter.run.return_value = 41
        other_experimenter = type('OtherMockExperimenter', (Experimenter,), {})
        other_experimenter.__init__ = MagicMock(return_value=None)
        other_experimenter.run = MagicMock(return_value = pandas.DataFrame({0: [1, 2], 2: [4, 5]}))
        expected = pandas.DataFrame({0: [1, 2], 2: [4, 5]})
        prev_data = [u'data from', u'previous get_data()', u'call']
        actual = self.agg_p.get_data([an_experimenter, other_experimenter], [], {}, prev_data)
        self.assertSequenceEqual(list(expected.index), list(actual.index))
        self.assertSequenceEqual(list(expected.columns), list(actual.columns))
        self.assertSequenceEqual(list(expected), list(actual))
        for piece in self.ind_pieces:
            self.assertEqual(0, piece.get_data.call_count)
        an_experimenter.__init__.assert_called_once_with(prev_data, {})
        an_experimenter.run.assert_called_once_with()
        other_experimenter.__init__.assert_called_once_with(an_experimenter.run.return_value, {})
        other_experimenter.run.assert_called_once_with()

    def test_get_data_11(self):
        # (based on test 5): one independent experimenter, one aggregated experimenter; provides
        # data from a (false) previous call to get_data()
        ind_experimenter = type('AMockExperimenter', (Experimenter,), {})
        agg_experimenter = type('OtherMockExperimenter', (Experimenter,), {})
        agg_experimenter.run = MagicMock(return_value = pandas.DataFrame({0: [1, 2], 2: [4, 5]}))
        expected = pandas.DataFrame({0: [1, 2], 2: [4, 5]})
        prev_data = [u'data from', u'previous get_data()', u'call']
        actual = self.agg_p.get_data([agg_experimenter], [ind_experimenter], {}, prev_data)
        self.assertSequenceEqual(list(expected.index), list(actual.index))
        self.assertSequenceEqual(list(expected.columns), list(actual.columns))
        self.assertSequenceEqual(list(expected), list(actual))
        for i, piece in enumerate(self.ind_pieces):
            piece.get_data.assert_called_once_with([ind_experimenter], {}, prev_data[i])
        agg_experimenter.run.assert_called_once_with()