@@ -608,7 +608,10 @@ def fixture_v_from_i(request):
608
608
609
609
610
610
@requires_scipy
611
- def test_v_from_i (fixture_v_from_i ):
611
+ @pytest .mark .parametrize (
612
+ 'method, atol' , [('lambertw' , 1e-11 ), ('brentq' , 1e-11 ), ('newton' , 1e-8 )]
613
+ )
614
+ def test_v_from_i (fixture_v_from_i , method , atol ):
612
615
# Solution set loaded from fixture
613
616
Rsh = fixture_v_from_i ['Rsh' ]
614
617
Rs = fixture_v_from_i ['Rs' ]
@@ -618,54 +621,7 @@ def test_v_from_i(fixture_v_from_i):
618
621
IL = fixture_v_from_i ['IL' ]
619
622
V_expected = fixture_v_from_i ['V_expected' ]
620
623
621
- # Convergence criteria
622
- atol = 1.e-11
623
-
624
- V = pvsystem .v_from_i (Rsh , Rs , nNsVth , I , I0 , IL )
625
- assert (isinstance (V , type (V_expected )))
626
- if isinstance (V , type (np .ndarray )):
627
- assert (isinstance (V .dtype , type (V_expected .dtype )))
628
- assert (V .shape == V_expected .shape )
629
- assert_allclose (V , V_expected , atol = atol )
630
-
631
-
632
- @requires_scipy
633
- def test_v_from_i_brentq (fixture_v_from_i ):
634
- # Solution set loaded from fixture
635
- Rsh = fixture_v_from_i ['Rsh' ]
636
- Rs = fixture_v_from_i ['Rs' ]
637
- nNsVth = fixture_v_from_i ['nNsVth' ]
638
- I = fixture_v_from_i ['I' ]
639
- I0 = fixture_v_from_i ['I0' ]
640
- IL = fixture_v_from_i ['IL' ]
641
- V_expected = fixture_v_from_i ['V_expected' ]
642
-
643
- # Convergence criteria
644
- atol = 1.e-11
645
-
646
- V = pvsystem .v_from_i (Rsh , Rs , nNsVth , I , I0 , IL , method = 'brentq' )
647
- assert (isinstance (V , type (V_expected )))
648
- if isinstance (V , type (np .ndarray )):
649
- assert (isinstance (V .dtype , type (V_expected .dtype )))
650
- assert (V .shape == V_expected .shape )
651
- assert_allclose (V , V_expected , atol = atol )
652
-
653
-
654
- @requires_scipy
655
- def test_v_from_i_newton (fixture_v_from_i ):
656
- # Solution set loaded from fixture
657
- Rsh = fixture_v_from_i ['Rsh' ]
658
- Rs = fixture_v_from_i ['Rs' ]
659
- nNsVth = fixture_v_from_i ['nNsVth' ]
660
- I = fixture_v_from_i ['I' ]
661
- I0 = fixture_v_from_i ['I0' ]
662
- IL = fixture_v_from_i ['IL' ]
663
- V_expected = fixture_v_from_i ['V_expected' ]
664
-
665
- # Convergence criteria
666
- atol = 1.e-8
667
-
668
- V = pvsystem .v_from_i (Rsh , Rs , nNsVth , I , I0 , IL , method = 'newton' )
624
+ V = pvsystem .v_from_i (Rsh , Rs , nNsVth , I , I0 , IL , method = method )
669
625
assert (isinstance (V , type (V_expected )))
670
626
if isinstance (V , type (np .ndarray )):
671
627
assert (isinstance (V .dtype , type (V_expected .dtype )))
@@ -772,7 +728,10 @@ def fixture_i_from_v(request):
772
728
773
729
774
730
@requires_scipy
775
- def test_i_from_v (fixture_i_from_v ):
731
+ @pytest .mark .parametrize (
732
+ 'method, atol' , [('lambertw' , 1e-11 ), ('brentq' , 1e-11 ), ('newton' , 1e-11 )]
733
+ )
734
+ def test_i_from_v (fixture_i_from_v , method , atol ):
776
735
# Solution set loaded from fixture
777
736
Rsh = fixture_i_from_v ['Rsh' ]
778
737
Rs = fixture_i_from_v ['Rs' ]
@@ -782,54 +741,7 @@ def test_i_from_v(fixture_i_from_v):
782
741
IL = fixture_i_from_v ['IL' ]
783
742
I_expected = fixture_i_from_v ['I_expected' ]
784
743
785
- # Convergence criteria
786
- atol = 1.e-11
787
-
788
- I = pvsystem .i_from_v (Rsh , Rs , nNsVth , V , I0 , IL , method = 'lambertw' )
789
- assert (isinstance (I , type (I_expected )))
790
- if isinstance (I , type (np .ndarray )):
791
- assert (isinstance (I .dtype , type (I_expected .dtype )))
792
- assert (I .shape == I_expected .shape )
793
- assert_allclose (I , I_expected , atol = atol )
794
-
795
-
796
- @requires_scipy
797
- def test_i_from_v_brentq (fixture_i_from_v ):
798
- # Solution set loaded from fixture
799
- Rsh = fixture_i_from_v ['Rsh' ]
800
- Rs = fixture_i_from_v ['Rs' ]
801
- nNsVth = fixture_i_from_v ['nNsVth' ]
802
- V = fixture_i_from_v ['V' ]
803
- I0 = fixture_i_from_v ['I0' ]
804
- IL = fixture_i_from_v ['IL' ]
805
- I_expected = fixture_i_from_v ['I_expected' ]
806
-
807
- # Convergence criteria
808
- atol = 1.e-11
809
-
810
- I = pvsystem .i_from_v (Rsh , Rs , nNsVth , V , I0 , IL , method = 'brentq' )
811
- assert (isinstance (I , type (I_expected )))
812
- if isinstance (I , type (np .ndarray )):
813
- assert (isinstance (I .dtype , type (I_expected .dtype )))
814
- assert (I .shape == I_expected .shape )
815
- assert_allclose (I , I_expected , atol = atol )
816
-
817
-
818
- @requires_scipy
819
- def test_i_from_v_newton (fixture_i_from_v ):
820
- # Solution set loaded from fixture
821
- Rsh = fixture_i_from_v ['Rsh' ]
822
- Rs = fixture_i_from_v ['Rs' ]
823
- nNsVth = fixture_i_from_v ['nNsVth' ]
824
- V = fixture_i_from_v ['V' ]
825
- I0 = fixture_i_from_v ['I0' ]
826
- IL = fixture_i_from_v ['IL' ]
827
- I_expected = fixture_i_from_v ['I_expected' ]
828
-
829
- # Convergence criteria
830
- atol = 1.e-11
831
-
832
- I = pvsystem .i_from_v (Rsh , Rs , nNsVth , V , I0 , IL , method = 'newton' )
744
+ I = pvsystem .i_from_v (Rsh , Rs , nNsVth , V , I0 , IL , method = method )
833
745
assert (isinstance (I , type (I_expected )))
834
746
if isinstance (I , type (np .ndarray )):
835
747
assert (isinstance (I .dtype , type (I_expected .dtype )))
0 commit comments