File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,9 @@ class PVSystem:
98
98
arrays : iterable of Array, optional
99
99
List of arrays that are part of the system. If not specified
100
100
a single array is created from the other parameters (e.g.
101
- `surface_tilt`, `surface_azimuth`). If `arrays` is specified
102
- the following parameters are ignored:
101
+ `surface_tilt`, `surface_azimuth`). Must contain at least one Array,
102
+ if length of arrays is 0 a ValueError is raised. If `arrays` is
103
+ specified the following parameters are ignored:
103
104
104
105
- `surface_tilt`
105
106
- `surface_azimuth`
@@ -173,6 +174,11 @@ class PVSystem:
173
174
Arbitrary keyword arguments.
174
175
Included for compatibility, but not used.
175
176
177
+ Raises
178
+ ------
179
+ ValueError
180
+ If `arrays` is not None and has length 0.
181
+
176
182
See also
177
183
--------
178
184
pvlib.location.Location
@@ -210,6 +216,12 @@ def __init__(self,
210
216
racking_model ,
211
217
array_losses_parameters ,
212
218
),)
219
+ elif len (arrays ) == 0 :
220
+ raise ValueError ("PVSystem must have at least one Array. "
221
+ "If you want to create a PVSystem instance "
222
+ "with a single Array pass `arrays=None` and pass "
223
+ "values directly to PVSystem attributes, e.g., "
224
+ "`surface_tilt=30`" )
213
225
else :
214
226
self .arrays = tuple (arrays )
215
227
Original file line number Diff line number Diff line change @@ -2067,6 +2067,12 @@ def test_PVSystem_num_arrays():
2067
2067
assert system_two .num_arrays == 2
2068
2068
2069
2069
2070
+ def test_PVSystem_at_least_one_array ():
2071
+ with pytest .raises (ValueError ,
2072
+ match = "PVSystem must have at least one Array" ):
2073
+ pvsystem .PVSystem (arrays = [])
2074
+
2075
+
2070
2076
def test_combine_loss_factors ():
2071
2077
test_index = pd .date_range (start = '1990/01/01T12:00' , periods = 365 , freq = 'D' )
2072
2078
loss_1 = pd .Series (.10 , index = test_index )
You can’t perform that action at this time.
0 commit comments