Skip to content

Commit 783ddf3

Browse files
committed
replace PVSystem iam tests with mocked versions
1 parent d2c9bcd commit 783ddf3

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

pvlib/test/test_pvsystem.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,13 @@ def test_ashraeiam_scalar():
113113
assert_allclose(iam, expected, equal_nan=True)
114114

115115

116-
@needs_numpy_1_10
117-
def test_PVSystem_ashraeiam():
116+
def test_PVSystem_ashraeiam(mocker):
118117
module_parameters = pd.Series({'b': 0.05})
119118
system = pvsystem.PVSystem(module_parameters=module_parameters)
120-
thetas = np.array([-90. , -67.5, -45. , -22.5, 0. , 22.5, 45. , 67.5, 89., 90. , np.nan])
119+
m = mocker.patch('pvlib.pvsystem.ashraeiam')
120+
thetas = None
121121
iam = system.ashraeiam(thetas)
122-
expected = np.array([ 0, 0.9193437 , 0.97928932, 0.99588039, 1. ,
123-
0.99588039, 0.97928932, 0.9193437 , 0, 0, np.nan])
124-
assert_allclose(iam, expected, equal_nan=True)
122+
m.assert_called_once_with(thetas, **module_parameters)
125123

126124

127125
@needs_numpy_1_10
@@ -151,15 +149,13 @@ def test_physicaliam_scalar():
151149
assert_allclose(iam, expected, equal_nan=True)
152150

153151

154-
@needs_numpy_1_10
155-
def test_PVSystem_physicaliam():
152+
def test_PVSystem_physicaliam_mocked(mocker):
156153
module_parameters = pd.Series({'K': 4, 'L': 0.002, 'n': 1.526})
157154
system = pvsystem.PVSystem(module_parameters=module_parameters)
158-
thetas = np.array([-90. , -67.5, -45. , -22.5, 0. , 22.5, 45. , 67.5, 90. , np.nan])
155+
m = mocker.patch('pvlib.pvsystem.physicaliam')
156+
thetas = None
159157
iam = system.physicaliam(thetas)
160-
expected = np.array([ 0, 0.8893998 , 0.98797788, 0.99926198, 1,
161-
0.99926198, 0.98797788, 0.8893998 , 0, np.nan])
162-
assert_allclose(iam, expected, equal_nan=True)
158+
m.assert_called_once_with(thetas, **module_parameters)
163159

164160

165161
# if this completes successfully we'll be able to do more tests below.

0 commit comments

Comments
 (0)