|
1 | 1 | import pandas as pd
|
| 2 | +import numpy as np |
2 | 3 | from datetime import datetime
|
3 |
| -from pvlib.bifacial import pvfactors_timeseries |
| 4 | +from pvlib.bifacial import pvfactors_timeseries, PVFactorsReportBuilder |
4 | 5 | from conftest import requires_pvfactors
|
5 | 6 | import pytest
|
6 | 7 |
|
@@ -107,3 +108,43 @@ def test_pvfactors_timeseries_pandas_inputs(run_parallel_calculations):
|
107 | 108 |
|
108 | 109 | pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
|
109 | 110 | pd.testing.assert_series_equal(ipoa_back, expected_ipoa_back)
|
| 111 | + |
| 112 | + |
| 113 | +def test_build_1(): |
| 114 | + """Test that build correctly instantiates a dictionary, when passed a Nones |
| 115 | + for the report and pvarray arguments. |
| 116 | + """ |
| 117 | + report = None |
| 118 | + pvarray = None |
| 119 | + expected = {'total_inc_back': [np.nan], 'total_inc_front': [np.nan]} |
| 120 | + assert expected == PVFactorsReportBuilder.build(report, pvarray) |
| 121 | + |
| 122 | + |
| 123 | +def test_merge_1(): |
| 124 | + """Test that merge correctly returns the first element of the reports |
| 125 | + argument when there is only dictionary in reports. |
| 126 | + """ |
| 127 | + test_dict = {'total_inc_back': [1, 2, 3], 'total_inc_front': [4, 5, 6]} |
| 128 | + reports = [test_dict] |
| 129 | + assert test_dict == PVFactorsReportBuilder.merge(reports) |
| 130 | + |
| 131 | + |
| 132 | +def test_merge_2(): |
| 133 | + """Test that merge correctly combines two dictionary reports. |
| 134 | + """ |
| 135 | + test_dict_1 = {'total_inc_back': [1, 2], 'total_inc_front': [4, 5]} |
| 136 | + test_dict_2 = {'total_inc_back': [3], 'total_inc_front': [6]} |
| 137 | + expected = {'total_inc_back': [1, 2, 3], 'total_inc_front': [4, 5, 6]} |
| 138 | + reports = [test_dict_1, test_dict_2] |
| 139 | + assert expected == PVFactorsReportBuilder.merge(reports) |
| 140 | + |
| 141 | + |
| 142 | +def test_merge_3(): |
| 143 | + """Test that merge correctly combines three dictionary reports. |
| 144 | + """ |
| 145 | + test_dict_1 = {'total_inc_back': [1], 'total_inc_front': [4]} |
| 146 | + test_dict_2 = {'total_inc_back': [2], 'total_inc_front': [5]} |
| 147 | + test_dict_3 = {'total_inc_back': [3], 'total_inc_front': [6]} |
| 148 | + expected = {'total_inc_back': [1, 2, 3], 'total_inc_front': [4, 5, 6]} |
| 149 | + reports = [test_dict_1, test_dict_2, test_dict_3] |
| 150 | + assert expected == PVFactorsReportBuilder.merge(reports) |
0 commit comments