@@ -1204,9 +1204,11 @@ def test_ac_model_not_a_model(pvwatts_dc_pvwatts_ac_system, location, weather):
1204
1204
1205
1205
1206
1206
def test_infer_ac_model_invalid_params (location ):
1207
+ # only the keys are relevant here, using arbitrary values
1208
+ module_parameters = {'pdc0' : 1 , 'gamma_pdc' : 1 }
1207
1209
system = pvsystem .PVSystem (
1208
1210
arrays = [pvsystem .Array (
1209
- module_parameters = pvsystem . _DC_MODEL_PARAMS [ 'pvwatts' ]
1211
+ module_parameters = module_parameters
1210
1212
)],
1211
1213
inverter_parameters = {'foo' : 1 , 'bar' : 2 }
1212
1214
)
@@ -1676,7 +1678,9 @@ def test_unknown_attribute(sapm_dc_snl_ac_system, location):
1676
1678
mc .unknown_attribute
1677
1679
1678
1680
1679
- def test_inconsistent_array_params (location ):
1681
+ def test_inconsistent_array_params (location ,
1682
+ sapm_module_params ,
1683
+ cec_module_params ):
1680
1684
module_error = ".* selected for the DC model but one or more Arrays are " \
1681
1685
"missing one or more required parameters"
1682
1686
temperature_error = "could not infer temperature model from " \
@@ -1687,32 +1691,57 @@ def test_inconsistent_array_params(location):
1687
1691
different_module_system = pvsystem .PVSystem (
1688
1692
arrays = [
1689
1693
pvsystem .Array (
1690
- module_parameters = pvsystem . _DC_MODEL_PARAMS [ 'sapm' ] ),
1694
+ module_parameters = sapm_module_params ),
1691
1695
pvsystem .Array (
1692
- module_parameters = pvsystem . _DC_MODEL_PARAMS [ 'cec' ] ),
1696
+ module_parameters = cec_module_params ),
1693
1697
pvsystem .Array (
1694
- module_parameters = pvsystem . _DC_MODEL_PARAMS [ 'cec' ] )]
1698
+ module_parameters = cec_module_params )]
1695
1699
)
1696
1700
with pytest .raises (ValueError , match = module_error ):
1697
1701
ModelChain (different_module_system , location , dc_model = 'cec' )
1698
1702
different_temp_system = pvsystem .PVSystem (
1699
1703
arrays = [
1700
1704
pvsystem .Array (
1701
- module_parameters = pvsystem . _DC_MODEL_PARAMS [ 'cec' ] ,
1705
+ module_parameters = cec_module_params ,
1702
1706
temperature_model_parameters = {'a' : 1 ,
1703
1707
'b' : 1 ,
1704
1708
'deltaT' : 1 }),
1705
1709
pvsystem .Array (
1706
- module_parameters = pvsystem . _DC_MODEL_PARAMS [ 'cec' ] ,
1710
+ module_parameters = cec_module_params ,
1707
1711
temperature_model_parameters = {'a' : 2 ,
1708
1712
'b' : 2 ,
1709
1713
'deltaT' : 2 }),
1710
1714
pvsystem .Array (
1711
- module_parameters = pvsystem . _DC_MODEL_PARAMS [ 'cec' ] ,
1715
+ module_parameters = cec_module_params ,
1712
1716
temperature_model_parameters = {'b' : 3 , 'deltaT' : 3 })]
1713
1717
)
1714
1718
with pytest .raises (ValueError , match = temperature_error ):
1715
1719
ModelChain (different_temp_system , location ,
1716
1720
ac_model = 'sandia_multi' ,
1717
1721
aoi_model = 'no_loss' , spectral_model = 'no_loss' ,
1718
1722
temperature_model = 'sapm' )
1723
+
1724
+
1725
+ def test_modelchain__common_keys ():
1726
+ dictionary = {'a' : 1 , 'b' : 1 }
1727
+ series = pd .Series (dictionary )
1728
+ assert {'a' , 'b' } == modelchain ._common_keys (
1729
+ {'a' : 1 , 'b' : 1 }
1730
+ )
1731
+ assert {'a' , 'b' } == modelchain ._common_keys (
1732
+ pd .Series ({'a' : 1 , 'b' : 1 })
1733
+ )
1734
+ assert {'a' , 'b' } == modelchain ._common_keys (
1735
+ (dictionary , series )
1736
+ )
1737
+ no_a = dictionary .copy ()
1738
+ del no_a ['a' ]
1739
+ assert {'b' } == modelchain ._common_keys (
1740
+ (dictionary , no_a )
1741
+ )
1742
+ assert {'b' } == modelchain ._common_keys (
1743
+ (series , pd .Series (no_a ))
1744
+ )
1745
+ assert {'b' } == modelchain ._common_keys (
1746
+ (series , no_a )
1747
+ )
0 commit comments