Skip to content

Commit 54457f4

Browse files
committed
add pytest.warns where pvsystem.singlediode ivcurve_pnts is used in tests
1 parent 7fafac1 commit 54457f4

4 files changed

Lines changed: 26 additions & 14 deletions

File tree

pvlib/tests/ivtools/test_sde.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
from pvlib import pvsystem
44
from pvlib.ivtools import sde
5+
from pvlib._deprecation import pvlibDeprecationWarning
56

67

78
@pytest.fixture
@@ -11,12 +12,13 @@ def get_test_iv_params():
1112

1213
def test_fit_sandia_simple(get_test_iv_params, get_bad_iv_curves):
1314
test_params = get_test_iv_params
14-
testcurve = pvsystem.singlediode(photocurrent=test_params['IL'],
15-
saturation_current=test_params['I0'],
16-
resistance_shunt=test_params['Rsh'],
17-
resistance_series=test_params['Rs'],
18-
nNsVth=test_params['nNsVth'],
19-
ivcurve_pnts=300)
15+
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
16+
testcurve = pvsystem.singlediode(photocurrent=test_params['IL'],
17+
saturation_current=test_params['I0'],
18+
resistance_shunt=test_params['Rsh'],
19+
resistance_series=test_params['Rs'],
20+
nNsVth=test_params['nNsVth'],
21+
ivcurve_pnts=300)
2022
expected = tuple(test_params[k] for k in ['IL', 'I0', 'Rs', 'Rsh',
2123
'nNsVth'])
2224
result = sde.fit_sandia_simple(voltage=testcurve['v'],

pvlib/tests/ivtools/test_sdm.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from pvlib.ivtools import sdm
88
from pvlib import pvsystem
9+
from pvlib._deprecation import pvlibDeprecationWarning
910

1011
from pvlib.tests.conftest import requires_pysam, requires_statsmodels
1112

@@ -102,7 +103,9 @@ def test_fit_desoto_sandia(cec_params_cansol_cs5p_220p):
102103
tc = np.repeat(temp_cell, len(effective_irradiance))
103104
iph, io, rs, rsh, nnsvth = pvsystem.calcparams_desoto(
104105
ee, tc, alpha_sc=specs['alpha_sc'], **params)
105-
sim_ivcurves = pvsystem.singlediode(iph, io, rs, rsh, nnsvth, 300)
106+
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
107+
sim_ivcurves = pvsystem.singlediode(iph, io, rs, rsh, nnsvth,
108+
ivcurve_pnts=300)
106109
sim_ivcurves['ee'] = ee
107110
sim_ivcurves['tc'] = tc
108111

pvlib/tests/test_pvsystem.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,9 @@ def test_singlediode_floats():
13581358

13591359

13601360
def test_singlediode_floats_ivcurve():
1361-
out = pvsystem.singlediode(7., 6e-7, .1, 20., .5, ivcurve_pnts=3,
1362-
method='lambertw')
1361+
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
1362+
out = pvsystem.singlediode(7., 6e-7, .1, 20., .5, ivcurve_pnts=3,
1363+
method='lambertw')
13631364
expected = {'i_xx': 4.264060478,
13641365
'i_mp': 6.136267360,
13651366
'v_oc': 8.106300147,
@@ -1391,8 +1392,9 @@ def test_singlediode_series_ivcurve(cec_module_params):
13911392
EgRef=1.121,
13921393
dEgdT=-0.0002677)
13931394

1394-
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3,
1395-
method='lambertw')
1395+
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
1396+
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3,
1397+
method='lambertw')
13961398

13971399
expected = OrderedDict([('i_sc', array([0., 3.01079860, 6.00726296])),
13981400
('v_oc', array([0., 9.96959733, 10.29603253])),
@@ -1411,7 +1413,8 @@ def test_singlediode_series_ivcurve(cec_module_params):
14111413
for k, v in out.items():
14121414
assert_allclose(v, expected[k], atol=1e-2)
14131415

1414-
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3)
1416+
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
1417+
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3)
14151418

14161419
expected['i_mp'] = pvsystem.i_from_v(out['v_mp'], IL, I0, Rs, Rsh, nNsVth,
14171420
method='lambertw')
@@ -1428,7 +1431,7 @@ def test_singlediode_series_ivcurve(cec_module_params):
14281431

14291432
@pytest.mark.parametrize('method', ['lambertw', 'brentq', 'newton'])
14301433
def test_singlediode_ivcurvepnts_deprecation_warning(method):
1431-
with pytest.warns(pvlibDeprecationWarning):
1434+
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
14321435
pvsystem.singlediode(7., 6e-7, .1, 20., .5, ivcurve_pnts=3,
14331436
method=method)
14341437

pvlib/tests/test_singlediode.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pvlib import pvsystem
99
from pvlib.singlediode import (bishop88_mpp, estimate_voc, VOLTAGE_BUILTIN,
1010
bishop88, bishop88_i_from_v, bishop88_v_from_i)
11+
from pvlib._deprecation import pvlibDeprecationWarning
1112
import pytest
1213
from .conftest import DATA_DIR
1314

@@ -176,7 +177,10 @@ def test_ivcurve_pnts_precision(method, precise_iv_curves):
176177
x, pc = precise_iv_curves
177178
pc_i, pc_v = np.stack(pc['Currents']), np.stack(pc['Voltages'])
178179
ivcurve_pnts = len(pc['Currents'][0])
179-
outs = pvsystem.singlediode(method=method, ivcurve_pnts=ivcurve_pnts, **x)
180+
181+
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
182+
outs = pvsystem.singlediode(method=method, ivcurve_pnts=ivcurve_pnts,
183+
**x)
180184

181185
assert np.allclose(pc_i, outs['i'], atol=1e-10, rtol=0)
182186
assert np.allclose(pc_v, outs['v'], atol=1e-10, rtol=0)

0 commit comments

Comments
 (0)