Exemplo n.º 1
0
 def test_offset_1part_0(self):
     # 0 parts
     in_val = []
     expected = []
     ind = FilterByRepeatIndexer(in_val)
     actual = ind.run()
     self.assertEqual(len(expected), len(actual))  # same number of parts?
Exemplo n.º 2
0
 def test_offset_1part_2(self):
     """input is expected output"""
     in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
     expected = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A',), ('0',)])
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Exemplo n.º 3
0
 def test_offset_1part_1a(self):
     """1 part with 0 length"""
     in_val = [pandas.Series()]
     expected = [pandas.Series()]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A',), ('0',)])
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Exemplo n.º 4
0
 def test_offset_1part_2(self):
     # input is expected output
     in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
     expected = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
     ind = FilterByRepeatIndexer(in_val)
     actual = ind.run()
     self.assertEqual(len(expected), len(actual))  # same number of parts?
     for i in xrange(len(expected)):  # compare each Series
         self.assertSequenceEqual(list(expected[i].index), list(actual[i].index))
         self.assertSequenceEqual(list(expected[i].values), list(actual[i].values))
Exemplo n.º 5
0
 def test_offset_1part_1(self):
     # 0 length
     # NOTE: this requires much more extensive testing in the multi-part suite
     in_val = [pandas.Series()]
     expected = [pandas.Series()]
     ind = FilterByRepeatIndexer(in_val)
     actual = ind.run()
     self.assertEqual(len(expected), len(actual))  # same number of parts?
     for part_i in xrange(len(expected)):
         # same number of rows?
         self.assertEqual(len(expected[part_i].index), len(actual[part_i].index))
Exemplo n.º 6
0
 def test_offset_1part_1b(self):
     """2 parts, one of which has 0 length"""
     in_val = [pandas.Series(),
               pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
     expected = [pandas.Series([nan, nan, nan, nan], index=[0.0, 0.5, 1.0, 1.5]),
                 pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A',), ('0', '1')])
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Exemplo n.º 7
0
 def test_offset_2parts_1(self):
     """pseudo-random, many parts"""
     temp1 = [pandas.Series(['d', 'd', 'a', 's', 's', 'd', 'f', 'a', 'f', 'f', 's', 'd', 'f',
                              's', 'f', 'd', 's', 's', 'a', 's'], index=range(1, 21))]*2
     in_val = pandas.concat(temp1, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A',), ('0', '1')])
     temp2 = [pandas.Series(['d','a','s','d','f','a','f','s','d','f','s','f','d','s','a','s'],
                           index=[1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20]),
             pandas.Series(['d','a','s','d','f','a','f','s','d','f','s','f','d','s','a','s'],
                           index=[1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20])]
     expected = pandas.concat(temp2, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Exemplo n.º 8
0
 def test_offset_1part_6(self):
     """pseudo-random"""
     in_val = [pandas.Series(['d', 'd', 'a', 's', 's', 'd', 'f', 'a', 'f', 'f', 's', 'd',
                              'f', 's', 'f', 'd', 's', 's', 'a', 's'],
                             index=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                                    17, 18, 19, 20])]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A',), ('0',)])
     expected = [pandas.Series(['d', 'a', 's', 'd', 'f', 'a', 'f', 's', 'd', 'f', 's', 'f',
                                     'd', 's', 'a', 's'],
                                    index=[1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20])]
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Exemplo n.º 9
0
 def test_offset_1part_6(self):
     # pseudo-random
     in_val = [pandas.Series(['d', 'd', 'a', 's', 's', 'd', 'f', 'a', 'f', 'f', 's', 'd',
                              'f', 's', 'f', 'd', 's', 's', 'a', 's'],
                             index=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                                    17, 18, 19, 20])]
     expected = [pandas.Series(['d', 'a', 's', 'd', 'f', 'a', 'f', 's', 'd', 'f', 's', 'f',
                                'd', 's', 'a', 's'],
                               index=[1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20])]
     ind = FilterByRepeatIndexer(in_val)
     actual = ind.run()
     self.assertEqual(len(expected), len(actual))  # same number of parts?
     for i in xrange(len(expected)):  # compare each Series
         self.assertSequenceEqual(list(expected[i].index), list(actual[i].index))
         self.assertSequenceEqual(list(expected[i].values), list(actual[i].values))