Esempio n. 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)
Esempio n. 2
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
Esempio n. 3
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)
Esempio n. 4
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
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 8
0
 def test_revenue_init_aligned_data_na_size(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     assert rev.aligned_data.isna().sum().all() == 0
     assert rev.aligned_data.shape == (8760, 3)
Esempio n. 9
0
 def test_revenue_init_defined_peak_hours(self, sample_data):
     pkhrs = PeakHours(peak=[4, 5, 1, 10], offpeak=[2, 3, 1, 8, 9])
     rev = GrossRevenue(aligned_data=sample_data, peak_hours=pkhrs)
     val = rev.peak_hours.get_peak_hours()
     assert (val[0] == [4, 5, 1, 10]).all()
     assert (val[1] == [2, 3, 1, 8, 9]).all()
Esempio n. 10
0
 def test_revenue_init_default_peak_hours(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     val = rev.peak_hours.get_peak_hours()
     assert (val[0] == peak_default).all()
     assert (val[1] == off_peak_default).all()
Esempio n. 11
0
 def test_calculate_gross_revenue(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.calculate_gross_revenue()
     assert os.path.isfile('GrossRevenue-PeakHrs.csv')
     assert os.path.isfile('GrossRevenue-OffPeakHrs.csv')
Esempio n. 12
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)