2222
2323from tests .test_singlediode import get_pvsyst_fs_495
2424
25+ from .conftest import chandrupatla , chandrupatla_available
26+
2527
2628@pytest .mark .parametrize ('iam_model,model_params' , [
2729 ('ashrae' , {'b' : 0.05 }),
@@ -1371,8 +1373,11 @@ def fixture_i_from_v(request):
13711373
13721374
13731375@pytest .mark .parametrize (
1374- 'method, atol' , [('lambertw' , 1e-11 ), ('brentq' , 1e-11 ), ('newton' , 1e-11 ),
1375- ('chandrupatla' , 1e-11 )]
1376+ 'method, atol' , [
1377+ ('lambertw' , 1e-11 ), ('brentq' , 1e-11 ), ('newton' , 1e-11 ),
1378+ pytest .param ("chandrupatla" , 1e-11 ,
1379+ marks = pytest .mark .skipif (not chandrupatla_available )),
1380+ ]
13761381)
13771382def test_i_from_v (fixture_i_from_v , method , atol ):
13781383 # Solution set loaded from fixture
@@ -1401,50 +1406,42 @@ def test_PVSystem_i_from_v(mocker):
14011406 m .assert_called_once_with (* args )
14021407
14031408
1404- def test_i_from_v_size ():
1405- with pytest .raises (ValueError ):
1406- pvsystem .i_from_v ([7.5 ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 )
1407- with pytest .raises (ValueError ):
1408- pvsystem .i_from_v ([7.5 ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 ,
1409- method = 'brentq' )
1410- with pytest .raises (ValueError ):
1411- pvsystem .i_from_v ([7.5 ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 ,
1412- method = 'chandrupatla' )
1409+ @pytest .mark .parametrize ('method' , ['lambertw' , 'brentq' , 'newton' ,
1410+ chandrupatla ])
1411+ def test_i_from_v_size (method ):
1412+ if method == 'newton' :
1413+ args = ([7.5 ] * 3 , np .array ([7. , 7. ]), 6e-7 , 0.1 , 20 , 0.5 )
1414+ else :
1415+ args = ([7.5 ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 )
14131416 with pytest .raises (ValueError ):
1414- pvsystem .i_from_v ([7.5 ] * 3 , np .array ([7. , 7. ]), 6e-7 , 0.1 , 20 , 0.5 ,
1415- method = 'newton' )
1417+ pvsystem .i_from_v (* args , method = method )
14161418
14171419
1418- def test_v_from_i_size ():
1419- with pytest .raises (ValueError ):
1420- pvsystem .v_from_i ([3. ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 )
1421- with pytest .raises (ValueError ):
1422- pvsystem .v_from_i ([3. ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 ,
1423- method = 'brentq' )
1424- with pytest .raises (ValueError ):
1425- pvsystem .v_from_i ([3. ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 ,
1426- method = 'chandrupatla' )
1420+ @pytest .mark .parametrize ('method' , ['lambertw' , 'brentq' , 'newton' ,
1421+ chandrupatla ])
1422+ def test_v_from_i_size (method ):
1423+ if method == 'newton' :
1424+ args = ([3. ] * 3 , np .array ([7. , 7. ]), 6e-7 , [0.1 ], 20 , 0.5 )
1425+ else :
1426+ args = ([3. ] * 3 , 7. , 6e-7 , [0.1 ] * 2 , 20 , 0.5 )
14271427 with pytest .raises (ValueError ):
1428- pvsystem .v_from_i ([3. ] * 3 , np .array ([7. , 7. ]), 6e-7 , [0.1 ], 20 , 0.5 ,
1429- method = 'newton' )
1428+ pvsystem .v_from_i (* args , method = method )
14301429
14311430
1432- def test_mpp_floats ():
1431+ @pytest .mark .parametrize ('method' , ['brentq' , 'newton' , chandrupatla ])
1432+ def test_mpp_floats (method ):
14331433 """test max_power_point"""
14341434 IL , I0 , Rs , Rsh , nNsVth = (7 , 6e-7 , .1 , 20 , .5 )
1435- out = pvsystem .max_power_point (IL , I0 , Rs , Rsh , nNsVth , method = 'brentq' )
1435+ out = pvsystem .max_power_point (IL , I0 , Rs , Rsh , nNsVth , method = method )
14361436 expected = {'i_mp' : 6.1362673597376753 , # 6.1390251797935704, lambertw
14371437 'v_mp' : 6.2243393757884284 , # 6.221535886625464, lambertw
14381438 'p_mp' : 38.194210547580511 } # 38.194165464983037} lambertw
14391439 assert isinstance (out , dict )
14401440 for k , v in out .items ():
14411441 assert np .isclose (v , expected [k ])
1442- out = pvsystem .max_power_point (IL , I0 , Rs , Rsh , nNsVth , method = 'newton' )
1443- for k , v in out .items ():
1444- assert np .isclose (v , expected [k ])
14451442
14461443
1447- @pytest .mark .parametrize ('method' , ['brentq' , 'newton' , ' chandrupatla' ])
1444+ @pytest .mark .parametrize ('method' , ['brentq' , 'newton' , chandrupatla ])
14481445def test_mpp_recombination (method ):
14491446 """test max_power_point"""
14501447 pvsyst_fs_495 = get_pvsyst_fs_495 ()
@@ -1475,7 +1472,7 @@ def test_mpp_recombination(method):
14751472 assert np .isclose (v , expected [k ], 0.01 )
14761473
14771474
1478- @pytest .mark .parametrize ('method' , ['brentq' , 'newton' , ' chandrupatla' ])
1475+ @pytest .mark .parametrize ('method' , ['brentq' , 'newton' , chandrupatla ])
14791476def test_mpp_array (method ):
14801477 """test max_power_point"""
14811478 IL , I0 , Rs , Rsh , nNsVth = (np .array ([7 , 7 ]), 6e-7 , .1 , 20 , .5 )
@@ -1488,7 +1485,7 @@ def test_mpp_array(method):
14881485 assert np .allclose (v , expected [k ])
14891486
14901487
1491- @pytest .mark .parametrize ('method' , ['brentq' , 'newton' , ' chandrupatla' ])
1488+ @pytest .mark .parametrize ('method' , ['brentq' , 'newton' , chandrupatla ])
14921489def test_mpp_series (method ):
14931490 """test max_power_point"""
14941491 idx = ['2008-02-17T11:30:00-0800' , '2008-02-17T12:30:00-0800' ]
0 commit comments