Skip to content

Commit 00108d9

Browse files
committed
fix dict update, a couple of tests
1 parent dfb0f43 commit 00108d9

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

pvlib/modelchain.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
)
3535
# update when full pvsyst models are known
3636
PVSYST_CONFIG = dict(
37-
dc_model='pvsyst'
37+
dc_model='pvsyst', spectral_model='no_loss'
3838
)
3939

4040

@@ -411,8 +411,9 @@ def with_pvwatts(cls, system, location,
411411
Name of ModelChain instance.
412412
413413
**kwargs
414-
Arbitrary keyword arguments. Included for compatibility, but not
415-
used.
414+
Parameters supplied here are passed to the ModelChain
415+
constructor and take precedence over the default
416+
configuration.
416417
417418
Examples
418419
--------
@@ -437,16 +438,16 @@ def with_pvwatts(cls, system, location,
437438
temperature_model: sapm_temp
438439
losses_model: pvwatts_losses
439440
"""
440-
441-
kwargs.update(PVWATTS_CONFIG)
441+
config = PVWATTS_CONFIG.copy()
442+
config.update(kwargs)
442443
return ModelChain(
443444
system, location,
444445
orientation_strategy=orientation_strategy,
445446
clearsky_model=clearsky_model,
446447
airmass_model=airmass_model,
447448
temperature_model=temperature_model,
448449
name=name,
449-
**kwargs
450+
**config
450451
)
451452

452453
@classmethod
@@ -494,8 +495,9 @@ def with_sapm(cls, system, location,
494495
Name of ModelChain instance.
495496
496497
**kwargs
497-
Arbitrary keyword arguments. Included for compatibility, but not
498-
used.
498+
Parameters supplied here are passed to the ModelChain
499+
constructor and take precedence over the default
500+
configuration.
499501
500502
Examples
501503
--------
@@ -522,8 +524,8 @@ def with_sapm(cls, system, location,
522524
temperature_model: sapm_temp
523525
losses_model: no_extra_losses
524526
"""
525-
526-
kwargs.update(SAPM_CONFIG)
527+
config = SAPM_CONFIG.copy()
528+
config.update(kwargs)
527529
return ModelChain(
528530
system, location,
529531
orientation_strategy=orientation_strategy,
@@ -532,7 +534,7 @@ def with_sapm(cls, system, location,
532534
solar_position_method=solar_position_method,
533535
airmass_model=airmass_model,
534536
name=name,
535-
**kwargs
537+
**config
536538
)
537539

538540
# update when full pvsyst models are known
@@ -581,8 +583,9 @@ def with_pvsyst(cls, system, location,
581583
Name of ModelChain instance.
582584
583585
**kwargs
584-
Arbitrary keyword arguments. Included for compatibility, but not
585-
used.
586+
Parameters supplied here are passed to the ModelChain
587+
constructor and take precedence over the default
588+
configuration.
586589
587590
Examples
588591
--------
@@ -609,8 +612,8 @@ def with_pvsyst(cls, system, location,
609612
temperature_model: sapm_temp
610613
losses_model: no_extra_losses
611614
"""
612-
613-
kwargs.update(PVSYST_CONFIG)
615+
config = PVSYST_CONFIG.copy()
616+
config.update(kwargs)
614617
return ModelChain(
615618
system, location,
616619
orientation_strategy=orientation_strategy,
@@ -619,7 +622,7 @@ def with_pvsyst(cls, system, location,
619622
solar_position_method=solar_position_method,
620623
airmass_model=airmass_model,
621624
name=name,
622-
**kwargs
625+
**config
623626
)
624627

625628
def __repr__(self):

pvlib/tests/test_modelchain.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@ def test_ModelChain_creation(sapm_dc_snl_ac_system, location):
170170
ModelChain(sapm_dc_snl_ac_system, location)
171171

172172

173+
def test_with_pvsyst(pvsyst_dc_snl_ac_system, location):
174+
mc = ModelChain.with_pvsyst(pvsyst_dc_snl_ac_system, location)
175+
assert mc.dc_model == mc.pvsyst
176+
177+
178+
def test_with_sapm(sapm_dc_snl_ac_system, location):
179+
mc = ModelChain.with_sapm(sapm_dc_snl_ac_system, location)
180+
assert mc.dc_model == mc.sapm
181+
182+
183+
def test_with_pvwatts(pvwatts_dc_pvwatts_ac_system, location):
184+
mc = ModelChain.with_pvwatts(pvwatts_dc_pvwatts_ac_system, location)
185+
assert mc.dc_model == mc.pvwatts_dc
186+
187+
173188
@pytest.mark.parametrize('strategy, expected', [
174189
(None, (32.2, 180)), ('None', (32.2, 180)), ('flat', (0, 180)),
175190
('south_at_latitude_tilt', (32.2, 180))

0 commit comments

Comments
 (0)