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)
 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)
 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)
 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)
    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)
def job(outfile_path1, infile_path, categories):

    tbl_n_categories = agg.custom_pd_read_table(infile_path,
                                                dtype=dict(n=float,
                                                           nvar=float))

    if tbl_n_categories.empty: return

    tbl_out = agg.sum_over_categories(tbl_n_categories,
                                      categories=tuple(categories),
                                      variables=('n', 'nvar'))

    if tbl_out is None: return
    if tbl_out.empty: return

    agg.write_to_file(tbl_out, outfile_path1)
 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)
Beispiel #8
0
                                                 tbl_sm_component_process,
                                                 tbl_qcd_nevt, tbl_qcd_xsec)

tbl_qcd_xi = ag.combine_mc_components(tbl_qcd_xi, tbl_sm_component_process,
                                      tbl_qcd_nevt, tbl_qcd_xsec)

tbl_t1tttt_minOmegaTilde = ag.split_component_for_smsmass(
    tbl_t1tttt_minOmegaTilde)

tbl_t1tttt_xi = ag.split_component_for_smsmass(tbl_t1tttt_xi)

#
# sum over MHT bins
#
tbl_qcd_minOmegaTilde = ag.sum_over_categories(tbl_qcd_minOmegaTilde,
                                               categories=['mhtbin'],
                                               variables=['n', 'nvar'])

tbl_qcd_xi = ag.sum_over_categories(tbl_qcd_xi,
                                    categories=['mhtbin'],
                                    variables=['n', 'nvar'])

tbl_t1tttt_minOmegaTilde = ag.sum_over_categories(tbl_t1tttt_minOmegaTilde,
                                                  categories=['mhtbin'],
                                                  variables=['n', 'nvar'])

tbl_t1tttt_xi = ag.sum_over_categories(tbl_t1tttt_xi,
                                       categories=['mhtbin'],
                                       variables=['n', 'nvar'])

#