File tree 3 files changed +18
-6
lines changed
docs/sphinx/source/whatsnew
3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ Enhancements
22
22
* Added :py:func: `~pvlib.iam.interp ` option as AOI losses model in
23
23
:py:class: `pvlib.modelchain.ModelChain ` and
24
24
:py:class: `pvlib.pvsystem.PVSystem `. (:issue: `1742 `, :pull: `1832 `)
25
+ * :py:class: `~pvlib.pvsystem.PVSystem ` objects with a single
26
+ :py:class: `~pvlib.pvsystem.Array ` can now be created without wrapping the
27
+ ``Array `` in a list first. (:issue: `1831 `, :pull: `1854 `)
25
28
26
29
Bug fixes
27
30
~~~~~~~~~
Original file line number Diff line number Diff line change @@ -101,10 +101,11 @@ class PVSystem:
101
101
102
102
Parameters
103
103
----------
104
- arrays : iterable of Array, optional
105
- List of arrays that are part of the system. If not specified
106
- a single array is created from the other parameters (e.g.
107
- `surface_tilt`, `surface_azimuth`). Must contain at least one Array,
104
+ arrays : Array or iterable of Array, optional
105
+ An Array or list of arrays that are part of the system. If not
106
+ specified a single array is created from the other parameters (e.g.
107
+ `surface_tilt`, `surface_azimuth`). If specified as a list, the list
108
+ must contain at least one Array;
108
109
if length of arrays is 0 a ValueError is raised. If `arrays` is
109
110
specified the following PVSystem parameters are ignored:
110
111
@@ -220,6 +221,8 @@ def __init__(self,
220
221
strings_per_inverter ,
221
222
array_losses_parameters ,
222
223
),)
224
+ elif isinstance (arrays , Array ):
225
+ self .arrays = (arrays ,)
223
226
elif len (arrays ) == 0 :
224
227
raise ValueError ("PVSystem must have at least one Array. "
225
228
"If you want to create a PVSystem instance "
Original file line number Diff line number Diff line change @@ -1887,8 +1887,6 @@ def test_PVSystem_multiple_array_creation():
1887
1887
assert pv_system .arrays [0 ].module_parameters == {}
1888
1888
assert pv_system .arrays [1 ].module_parameters == {'pdc0' : 1 }
1889
1889
assert pv_system .arrays == (array_one , array_two )
1890
- with pytest .raises (TypeError ):
1891
- pvsystem .PVSystem (arrays = array_one )
1892
1890
1893
1891
1894
1892
def test_PVSystem_get_aoi ():
@@ -2362,6 +2360,14 @@ def test_PVSystem_at_least_one_array():
2362
2360
pvsystem .PVSystem (arrays = [])
2363
2361
2364
2362
2363
+ def test_PVSystem_single_array ():
2364
+ # GH 1831
2365
+ single_array = pvsystem .Array (pvsystem .FixedMount ())
2366
+ system = pvsystem .PVSystem (arrays = single_array )
2367
+ assert isinstance (system .arrays , tuple )
2368
+ assert system .arrays [0 ] is single_array
2369
+
2370
+
2365
2371
def test_combine_loss_factors ():
2366
2372
test_index = pd .date_range (start = '1990/01/01T12:00' , periods = 365 , freq = 'D' )
2367
2373
loss_1 = pd .Series (.10 , index = test_index )
You can’t perform that action at this time.
0 commit comments