Skip to content

Commit 4f6584a

Browse files
veronicaguocwhanse
authored andcommitted
Don't expose model parameter dictionaries to users (pvlib#805)
* Don't expose model parameter dicts to users * Update whatsnew * Update whatsnew for private dictionaries
1 parent 4250d71 commit 4f6584a

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ API Changes
7777
- `pvsystem.physicaliam` is `iam.physical`
7878
- `pvsystem.ashraeiam` is `iam.ashrae`
7979
- `pvsystem.sapm_aoi_loss` is `iam.sapm`
80-
- Created dict `iam.IAM_MODEL_PARAMS` to aid in identifying IAM models
8180
* Changes to `PVSystem` class
8281
- IAM models are provided by `PVSystem.get_iam` with kwarg `iam_model`.
8382
- Methods `PVSystem.ashraeiam`, `PVSystem.physicaliam` and
@@ -94,6 +93,8 @@ API Changes
9493
The `weather` argument of the above methods is now the first, required
9594
positional argument and the `times` argument is kept as the second keyword
9695
argument for capability during the deprecation period.
96+
* Parameter `pvsystem.DC_MODEL_PARAMS` is renamed to `pvsystem._DC_MODEL_PARAMS`.
97+
Users should not rely on this dictionary's existence or structure.
9798

9899
Enhancements
99100
~~~~~~~~~~~~

pvlib/iam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# a dict of required parameter names for each IAM model
1616
# keys are the function names for the IAM models
17-
IAM_MODEL_PARAMS = {
17+
_IAM_MODEL_PARAMS = {
1818
'ashrae': set(['b']),
1919
'physical': set(['n', 'K', 'L']),
2020
'martin_ruiz': set(['a_r']),

pvlib/modelchain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
tools)
1414
from pvlib.tracking import SingleAxisTracker
1515
import pvlib.irradiance # avoid name conflict with full import
16-
from pvlib.pvsystem import DC_MODEL_PARAMS
16+
from pvlib.pvsystem import _DC_MODEL_PARAMS
1717
from pvlib._deprecation import pvlibDeprecationWarning
1818

1919

@@ -395,9 +395,9 @@ def dc_model(self, model):
395395
# Set model and validate parameters
396396
if isinstance(model, str):
397397
model = model.lower()
398-
if model in DC_MODEL_PARAMS.keys():
398+
if model in _DC_MODEL_PARAMS.keys():
399399
# validate module parameters
400-
missing_params = DC_MODEL_PARAMS[model] - \
400+
missing_params = _DC_MODEL_PARAMS[model] - \
401401
set(self.system.module_parameters.keys())
402402
if missing_params: # some parameters are not in module.keys()
403403
raise ValueError(model + ' selected for the DC model but '

pvlib/pvsystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
# a dict of required parameter names for each DC power model
24-
DC_MODEL_PARAMS = {
24+
_DC_MODEL_PARAMS = {
2525
'sapm': set([
2626
'A0', 'A1', 'A2', 'A3', 'A4', 'B0', 'B1', 'B2', 'B3',
2727
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6',
@@ -345,7 +345,7 @@ def get_iam(self, aoi, iam_model='physical'):
345345
"""
346346
model = iam_model.lower()
347347
if model in ['ashrae', 'physical', 'martin_ruiz']:
348-
param_names = iam.IAM_MODEL_PARAMS[model]
348+
param_names = iam._IAM_MODEL_PARAMS[model]
349349
kwargs = _build_kwargs(param_names, self.module_parameters)
350350
func = getattr(iam, model)
351351
return func(aoi, **kwargs)

pvlib/test/test_modelchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def test_aoi_model_user_func(system, location, weather, mocker):
461461
'sapm', 'ashrae', 'physical', 'martin_ruiz'
462462
])
463463
def test_infer_aoi_model(location, system_no_aoi, aoi_model):
464-
for k in iam.IAM_MODEL_PARAMS[aoi_model]:
464+
for k in iam._IAM_MODEL_PARAMS[aoi_model]:
465465
system_no_aoi.module_parameters.update({k: 1.0})
466466
mc = ModelChain(system_no_aoi, location,
467467
orientation_strategy='None',

0 commit comments

Comments
 (0)