Beispiel #1
0
    def test_no_categories(self):
        expect = tbl_1_A_B_C
        actual = sum_over_categories(tbl_1_A_B_C,
                                     categories=(),
                                     variables=('n', 'nvar'))
        self.assertIsNot(tbl_1_A_B_C, actual)
        self.assertIsNot(expect, actual)
        self.assertEqual(expect, actual)

        expect = tbl_1_A_B_C
        actual = sum_over_categories(tbl_1_A_B_C,
                                     categories=None,
                                     variables=('n', 'nvar'))
        self.assertIsNot(tbl_1_A_B_C, actual)
        self.assertIsNot(expect, actual)
        self.assertEqual(expect, actual)
Beispiel #2
0
 def test_one_category(self):
     expect = tbl_1_A_B
     actual = sum_over_categories(tbl_1_A_B_C,
                                  categories=('C', ),
                                  variables=('n', 'nvar'))
     self.assertIsNot(tbl_1_A_B_C, actual)
     self.assertIsNot(expect, actual)
     self.assertEqual(expect, actual)
Beispiel #3
0
 def test_all_categories(self):
     expect = tbl_1
     actual = sum_over_categories(tbl_1_A_B_C,
                                  categories=('A', 'B', 'C'),
                                  variables=('n', 'nvar'))
     self.assertIsNot(tbl_1_A_B_C, actual)
     self.assertIsNot(expect, actual)
     self.assertEqual(expect, actual)
Beispiel #4
0
 def test_all_categories_with_variable_name_index(self):
     expect = tbl_1.rename(columns={'nvar': 'index'})
     tbl = tbl_1_A_B_C.rename(columns={'nvar': 'index'})
     actual = sum_over_categories(tbl,
                                  categories=('A', 'B', 'C'),
                                  variables=('n', 'index'))
     self.assertIsNot(tbl, actual)
     self.assertIsNot(expect, actual)
     self.assertEqual(expect, actual)
Beispiel #5
0
    def test_all_the_way(self):
        expect = tbl_1_A_B
        actual = sum_over_categories(tbl_1_A_B_C,
                                     categories=('C', ),
                                     variables=('n', 'nvar'))
        self.assertIsNot(tbl_1_A_B_C, actual)
        self.assertIsNot(expect, actual)
        self.assertEqual(expect, actual)

        expect = tbl_1_A
        actual = sum_over_categories(tbl_1_A_B,
                                     categories=('B', ),
                                     variables=('n', 'nvar'))
        self.assertIsNot(tbl_1_A_B, actual)
        self.assertIsNot(expect, actual)
        self.assertEqual(expect, actual)

        expect = tbl_1
        actual = sum_over_categories(tbl_1_A,
                                     categories=('A', ),
                                     variables=('n', 'nvar'))
        self.assertIsNot(tbl_1_A, actual)
        self.assertIsNot(expect, actual)
        self.assertEqual(expect, actual)
Beispiel #6
0
 def test_nonexistent_variables(self):
     expect = tbl_1_A_B
     actual = sum_over_categories(tbl_1_A_B_C,
                                  categories=('C', ),
                                  variables=('n', 'nvar', 'xxx'))
     self.assertEqual(expect, actual)