Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PVSystem with single Array generates an error #1831

Closed
cwhanse opened this issue Aug 10, 2023 · 0 comments · Fixed by #1854
Closed

PVSystem with single Array generates an error #1831

cwhanse opened this issue Aug 10, 2023 · 0 comments · Fixed by #1854

Comments

@cwhanse
Copy link
Member

cwhanse commented Aug 10, 2023

Is your feature request related to a problem? Please describe.

When a PVSystem has a single Array, you can't assign just the Array instance when constructing the PVSystem.

mount = pvlib.pvsystem.FixedMount(surface_tilt=35, surface_azimuth=180)
array = pvlib.pvsystem.Array(mount=mount)
pv = pvlib.pvsystem.PVSystem(arrays=array)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-f5424e3db16a> in <module>
      3 mount = pvlib.pvsystem.FixedMount(surface_tilt=35, surface_azimuth=180)
      4 array = pvlib.pvsystem.Array(mount=mount)
----> 5 pv = pvlib.pvsystem.PVSystem(arrays=array)

~\anaconda3\lib\site-packages\pvlib\pvsystem.py in __init__(self, arrays, surface_tilt, surface_azimuth, albedo, surface_type, module, module_type, module_parameters, temperature_model_parameters, modules_per_string, strings_per_inverter, inverter, inverter_parameters, racking_model, losses_parameters, name)
    251                 array_losses_parameters,
    252             ),)
--> 253         elif len(arrays) == 0:
    254             raise ValueError("PVSystem must have at least one Array. "
    255                              "If you want to create a PVSystem instance "

TypeError: object of type 'Array' has no len()

Not a bug per se, since the PVSystem docstring requests that arrays be iterable. Still, a bit inconvenient to have to do this

mount = pvlib.pvsystem.FixedMount(surface_tilt=35, surface_azimuth=180)
array = pvlib.pvsystem.Array(mount=mount)
pv = pvlib.pvsystem.PVSystem(arrays=[array])

Describe the solution you'd like
Handle arrays=array where array is an instance of Array

Describe alternatives you've considered
Status quo - either make the single Array into a list, or use the PVSystem kwargs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants