8000 add consistency tests to ModelChain.dc_model by cwhanse · Pull Request #548 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

add consistency tests to ModelChain.dc_model #548

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

Merged
merged 13 commits into from
Aug 31, 2018
Prev Previous commit
Next Next commit
Add handling of invalid model name string
  • Loading branch information
cwhanse committed Aug 29, 2018
commit 10a5f7d4889fd454f65cec41dced4d8215a811cb
29 changes: 15 additions & 14 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,21 @@ def dc_model(self, model):
# Set model and validate parameters
if isinstance(model, str):
model = model.lower()
# validate module parameters
missing_params = DC_MODEL_PARAMS[model] - \
set(self.system.module_parameters.keys())
if missing_params: # some parameters are not in module.keys()
raise ValueError(model + ' selected for the DC model but '
'one or more required parameters '
' are missing : ' +
str(missing_params))
if model == 'sapm':
self._dc_model = self.sapm
elif model == 'singlediode':
self._dc_model = self.singlediode
elif model == 'pvwatts':
self._dc_model = self.pvwatts_dc
if model in DC_MODEL_PARAMS.keys():
# validate module parameters
missing_params = DC_MODEL_PARAMS[model] - \
set(self.system.module_parameters.keys())
if missing_params: # some parameters are not in module.keys()
raise ValueError(model + ' selected for the DC model but '
'one or more required parameters '
' are missing : ' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space in string at end of previous line and beginning of this one, so remove one of them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

str(missing_params))
if model == 'sapm':
self._dc_model = self.sapm
elif model == 'singlediode':
self._dc_model = self.singlediode
elif model == 'pvwatts':
self._dc_model = self.pvwatts_dc
else:
raise ValueError(model + ' is not a valid DC power model')
else:
Expand Down
0