Skip to content

Commit 486cf38

Browse files
committed
remove list input
1 parent c658199 commit 486cf38

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

pvlib/iam.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True):
470470
pvlib.iam.sapm
471471
'''
472472
# Contributed by Anton Driesse (@adriesse), PV Performance Labs. July, 2019
473+
if isinstance(theta_ref, list):
474+
raise TypeError("theta_ref cannot be a list")
475+
if isinstance(iam_ref, list):
476+
raise TypeError("iam_ref cannot be a list")
473477
# Scipy doesn't give the clearest feedback, so check number of points here.
474478
MIN_REF_VALS = {'linear': 2, 'quadratic': 3, 'cubic': 4, 1: 2, 2: 3, 3: 4}
475479

@@ -481,9 +485,6 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True):
481485
raise ValueError("Negative value(s) found in 'iam_ref'. "
482486
"This is not physically possible.")
483487

484-
theta_ref = np.asarray(theta_ref)
485-
iam_ref = np.asarray(iam_ref)
486-
487488
if method == "linear":
488489
interpolator = make_interp_spline(theta_ref, iam_ref, k=1)
489490

tests/test_iam.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def test_martin_ruiz_diffuse():
171171

172172
def test_iam_interp():
173173

174-
aoi_meas = [0.0, 45.0, 65.0, 75.0]
175-
iam_meas = [1.0, 0.9, 0.8, 0.6]
174+
aoi_meas = np.array([0.0, 45.0, 65.0, 75.0])
175+
iam_meas = np.array([1.0, 0.9, 0.8, 0.6])
176176

177177
# simple default linear method
178178
aoi = 55.0
@@ -200,18 +200,18 @@ def test_iam_interp():
200200
assert_series_equal(iam, expected)
201201

202202
# check beyond reference values
203-
aoi = [-45, 0, 45, 85, 90, 95, 100, 105, 110]
204-
expected = [0.9, 1.0, 0.9, 0.4, 0.3, 0.2, 0.1, 0.0, 0.0]
203+
aoi = np.array([-45, 0, 45, 85, 90, 95, 100, 105, 110])
204+
expected = np.array([0.9, 1.0, 0.9, 0.4, 0.3, 0.2, 0.1, 0.0, 0.0])
205205
iam = _iam.interp(aoi, aoi_meas, iam_meas)
206206
assert_allclose(iam, expected)
207207

208208
# check exception clause
209209
with pytest.raises(ValueError):
210-
_iam.interp(0.0, [0], [1])
210+
_iam.interp(0.0, np.array([0]), np.array([1]))
211211

212212
# check exception clause
213213
with pytest.raises(ValueError):
214-
_iam.interp(0.0, [0, 90], [1, -1])
214+
_iam.interp(0.0, np.array([0, 90]), np.array([1, -1]))
215215

216216
# check linear after updating interp1d
217217
theta_ref = np.array([0, 60, 90])
@@ -239,6 +239,14 @@ def test_iam_interp():
239239
expected = 1.0 - 1e-4 * aoi**2
240240
np.testing.assert_allclose(iam, expected, rtol=1e-12)
241241

242+
# check exception clause - list input for theta_ref
243+
with pytest.raises(TypeError):
244+
_iam.interp(0.0, [0, 60, 90], np.array([1.0, 0.8, 0.0]))
245+
246+
# check exception clause - list input for iam_ref
247+
with pytest.raises(TypeError):
248+
_iam.interp(0.0, np.array([0, 60, 90]), [1.0, 0.8, 0.0])
249+
242250

243251
@pytest.mark.parametrize('aoi,expected', [
244252
(45, 0.9975036250000002),

0 commit comments

Comments
 (0)