Beispiel #1
0
 def test_add_revenue_value_spot_check(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     z = rev.aligned_data.iloc[42, :]
     assert isclose(z[0], 9.14, rel_tol=1e-04)
     assert isclose(z[1], 2517.049924, rel_tol=1e-04)
     assert isclose(z[2], 25.164100, rel_tol=1e-04)
     assert isclose(z[3], 6.333930, rel_tol=1e-04)
Beispiel #2
0
 def test_write_grouped_data_to_file(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf)
     outfile = "peak-data.csv"
     rev.save_grouped_data(grouped, outfile)
     assert os.path.isfile(outfile)
Beispiel #3
0
 def test_groupby_runs_default_methods(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf)
     assert grouped.shape == (12, 4)
     print(grouped)
     assert grouped.index.min() == 1
     assert grouped.index.max() == 12
Beispiel #4
0
 def test_subset_data_badpeak(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="perk")
     oncount = subdf.isna().sum()
     offcount = subdf.notnull().sum()
     for elem in oncount:
         assert elem == 4380
     for elem in offcount:
         assert elem == 4380
Beispiel #5
0
 def test_groupby_other_methods_spotcheck(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf, [max, min, max, min])
     z = grouped.iloc[6, :]
     print(z)
     assert isclose(z[0], 9.530556, rel_tol=1e-04)
     assert isclose(z[1], 131.111105, rel_tol=1e-04)
     assert isclose(z[2], 43.969100, rel_tol=1e-04)
     assert isclose(z[3], 0.309022, rel_tol=1e-04)
Beispiel #6
0
 def test_groupby_defaults_spotcheck(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf)
     z = grouped.iloc[6, :]
     print(z)
     assert isclose(z[0], 6.793248, rel_tol=1e-04)
     assert isclose(z[1], 1422.076282, rel_tol=1e-04)
     assert isclose(z[2], 10184.529100, rel_tol=1e-04)
     assert isclose(z[3], 1469.932431, rel_tol=1e-04)
Beispiel #7
0
 def test_add_revenue_column_na_size(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     assert rev.aligned_data.isna().sum().all() == 0
     assert rev.aligned_data.shape == (8760, 4)
Beispiel #8
0
 def test_groupby_runs_other_methods(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf, [max, min, max, min])
     assert grouped.shape == (12, 4)