Skip to content

Don't expose model parameter dictionaries to users #805

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 5 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/sphinx/source/whatsnew/v0.7.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ API Changes
- `pvsystem.physicaliam` is `iam.physical`
- `pvsystem.ashraeiam` is `iam.ashrae`
- `pvsystem.sapm_aoi_loss` is `iam.sapm`
- Created dict `iam.IAM_MODEL_PARAMS` to aid in identifying IAM models
* Changes to `PVSystem` class
- IAM models are provided by `PVSystem.get_iam` with kwarg `iam_model`.
- Methods `PVSystem.ashraeiam`, `PVSystem.physicaliam` and
Expand All @@ -94,6 +93,8 @@ API Changes
The `weather` argument of the above methods is now the first, required
positional argument and the `times` argument is kept as the second keyword
argument for capability during the deprecation period.
* Parameter `pvsystem.DC_MODEL_PARAMS` is renamed to `pvsystem._DC_MODEL_PARAMS`.
Users should not rely on this dictionary's existence or structure.

Enhancements
~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pvlib/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# a dict of required parameter names for each IAM model
# keys are the function names for the IAM models
IAM_MODEL_PARAMS = {
_IAM_MODEL_PARAMS = {
'ashrae': set(['b']),
'physical': set(['n', 'K', 'L']),
'martin_ruiz': set(['a_r']),
Expand Down
6 changes: 3 additions & 3 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
tools)
from pvlib.tracking import SingleAxisTracker
import pvlib.irradiance # avoid name conflict with full import
from pvlib.pvsystem import DC_MODEL_PARAMS
from pvlib.pvsystem import _DC_MODEL_PARAMS
from pvlib._deprecation import pvlibDeprecationWarning


Expand Down Expand Up @@ -395,9 +395,9 @@ def dc_model(self, model):
# Set model and validate parameters
if isinstance(model, str):
model = model.lower()
if model in DC_MODEL_PARAMS.keys():
if model in _DC_MODEL_PARAMS.keys():
# validate module parameters
missing_params = DC_MODEL_PARAMS[model] - \
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 '
Expand Down
4 changes: 2 additions & 2 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


# a dict of required parameter names for each DC power model
DC_MODEL_PARAMS = {
_DC_MODEL_PARAMS = {
'sapm': set([
'A0', 'A1', 'A2', 'A3', 'A4', 'B0', 'B1', 'B2', 'B3',
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6',
Expand Down Expand Up @@ -345,7 +345,7 @@ def get_iam(self, aoi, iam_model='physical'):
"""
model = iam_model.lower()
if model in ['ashrae', 'physical', 'martin_ruiz']:
param_names = iam.IAM_MODEL_PARAMS[model]
param_names = iam._IAM_MODEL_PARAMS[model]
kwargs = _build_kwargs(param_names, self.module_parameters)
func = getattr(iam, model)
return func(aoi, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion pvlib/test/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def test_aoi_model_user_func(system, location, weather, mocker):
'sapm', 'ashrae', 'physical', 'martin_ruiz'
])
def test_infer_aoi_model(location, system_no_aoi, aoi_model):
for k in iam.IAM_MODEL_PARAMS[aoi_model]:
for k in iam._IAM_MODEL_PARAMS[aoi_model]:
system_no_aoi.module_parameters.update({k: 1.0})
mc = ModelChain(system_no_aoi, location,
orientation_strategy='None',
Expand Down