Skip to content

Commit 816c82a

Browse files
committed
add tests
1 parent a018525 commit 816c82a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/test_pvsystem.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,46 @@ def test_pvwatts_dc_series():
21812181
assert_series_equal(expected, out)
21822182

21832183

2184+
def test_pvwatts_dc_scalars_with_k():
2185+
expected = 8.9125
2186+
out = pvsystem.pvwatts_dc(100, 30, 100, -0.003, 25, 0.01)
2187+
assert_allclose(out, expected)
2188+
2189+
2190+
def test_pvwatts_dc_arrays_with_k():
2191+
irrad_trans = np.array([np.nan, 100, 100])
2192+
temp_cell = np.array([30, np.nan, 30])
2193+
irrad_trans, temp_cell = np.meshgrid(irrad_trans, temp_cell)
2194+
expected = np.array([[nan, 8.9125, 8.9125],
2195+
[nan, nan, nan],
2196+
[nan, 8.9125, 8.9125]])
2197+
out = pvsystem.pvwatts_dc(irrad_trans, temp_cell, 100, -0.003, 25, 0.01)
2198+
assert_allclose(out, expected, equal_nan=True)
2199+
2200+
2201+
def test_pvwatts_dc_series_with_k():
2202+
irrad_trans = pd.Series([np.nan, 100, 100])
2203+
temp_cell = pd.Series([30, np.nan, 30])
2204+
expected = pd.Series(np.array([ nan, nan, 8.9125]))
2205+
out = pvsystem.pvwatts_dc(irrad_trans, temp_cell, 100, -0.003, 25, 0.01)
2206+
assert_series_equal(expected, out)
2207+
2208+
2209+
def test_pvwatts_dc_with_k_and_cap_adjustment():
2210+
irrad_trans = [100, 1200]
2211+
temp_cell = 25
2212+
ks = [0.01, 0.02]
2213+
cap_adjustments = [False, True]
2214+
out = []
2215+
expected = [9.0625, 120.25, 8.125, 120.5, 9.0625, 120.0, 8.125, 120.0]
2216+
for cap_adjustment in cap_adjustments:
2217+
for k in ks:
2218+
for irrad in irrad_trans:
2219+
out.append(pvsystem.pvwatts_dc(irrad, temp_cell, 100, -0.003,
2220+
25, k, cap_adjustment))
2221+
assert_allclose(out, expected)
2222+
2223+
21842224
def test_pvwatts_losses_default():
21852225
expected = 14.075660688264469
21862226
out = pvsystem.pvwatts_losses()

0 commit comments

Comments
 (0)