Skip to content

Commit 5f7109b

Browse files
authored
Allow PVSystems to be created with single Arrays (#1854)
* allow single Arrays * whatsnew
1 parent 27a3a07 commit 5f7109b

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

docs/sphinx/source/whatsnew/v0.10.2.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Enhancements
2222
* Added :py:func:`~pvlib.iam.interp` option as AOI losses model in
2323
:py:class:`pvlib.modelchain.ModelChain` and
2424
: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`)
2528

2629
Bug fixes
2730
~~~~~~~~~

pvlib/pvsystem.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ class PVSystem:
101101
102102
Parameters
103103
----------
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;
108109
if length of arrays is 0 a ValueError is raised. If `arrays` is
109110
specified the following PVSystem parameters are ignored:
110111
@@ -220,6 +221,8 @@ def __init__(self,
220221
strings_per_inverter,
221222
array_losses_parameters,
222223
),)
224+
elif isinstance(arrays, Array):
225+
self.arrays = (arrays,)
223226
elif len(arrays) == 0:
224227
raise ValueError("PVSystem must have at least one Array. "
225228
"If you want to create a PVSystem instance "

pvlib/tests/test_pvsystem.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,8 +1887,6 @@ def test_PVSystem_multiple_array_creation():
18871887
assert pv_system.arrays[0].module_parameters == {}
18881888
assert pv_system.arrays[1].module_parameters == {'pdc0': 1}
18891889
assert pv_system.arrays == (array_one, array_two)
1890-
with pytest.raises(TypeError):
1891-
pvsystem.PVSystem(arrays=array_one)
18921890

18931891

18941892
def test_PVSystem_get_aoi():
@@ -2362,6 +2360,14 @@ def test_PVSystem_at_least_one_array():
23622360
pvsystem.PVSystem(arrays=[])
23632361

23642362

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+
23652371
def test_combine_loss_factors():
23662372
test_index = pd.date_range(start='1990/01/01T12:00', periods=365, freq='D')
23672373
loss_1 = pd.Series(.10, index=test_index)

0 commit comments

Comments
 (0)