@@ -181,8 +181,8 @@ def weather():
181
181
@pytest .fixture
182
182
def total_irrad (weather ):
183
183
return pd .DataFrame ({'poa_global' : [800. , 500. ],
184
- 'poa_diffuse ' : [300 . , 200 . ],
185
- 'poa_direct ' : [500 . , 300 . ]}, index = weather .index )
184
+ 'poa_direct ' : [500 . , 300 . ],
185
+ 'poa_diffuse ' : [300 . , 200 . ]}, index = weather .index )
186
186
187
187
188
188
def test_ModelChain_creation (sapm_dc_snl_ac_system , location ):
@@ -336,21 +336,25 @@ def test_run_model_tracker(sapm_dc_snl_ac_system, location, weather, mocker):
336
336
337
337
def test__assign_total_irrad (sapm_dc_snl_ac_system , location , weather ,
338
338
total_irrad ):
339
- weather [[ 'poa_global' , 'poa_diffuse' , 'poa_direct' ]] = total_irrad
339
+ data = pd . concat ([ weather , total_irrad ], axis = 1 )
340
340
mc = ModelChain (sapm_dc_snl_ac_system , location )
341
- mc ._assign_total_irrad (weather )
342
- for k in modelchain .POA_DATA_KEYS :
343
- assert_series_equal (mc .total_irrad [k ], total_irrad [k ])
341
+ mc ._assign_total_irrad (data )
342
+ assert_frame_equal (mc .total_irrad , total_irrad )
344
343
345
344
346
345
def test_prepare_inputs_from_poa (sapm_dc_snl_ac_system , location ,
347
346
weather , total_irrad ):
348
- data = weather .copy ()
349
- data [['poa_global' , 'poa_diffuse' , 'poa_direct' ]] = total_irrad
347
+ data = pd .concat ([weather , total_irrad ], axis = 1 )
350
348
mc = ModelChain (sapm_dc_snl_ac_system , location )
351
349
mc .prepare_inputs_from_poa (data )
350
+ weather_expected = weather .copy ()
351
+ weather_expected ['temp_air' ] = 20
352
+ weather_expected ['wind_speed' ] = 0
353
+ # order as expected
354
+ weather_expected = weather_expected [
355
+ ['ghi' , 'dhi' , 'dni' , 'wind_speed' , 'temp_air' ]]
352
356
# weather attribute
353
- assert_frame_equal (mc .weather , weather )
357
+ assert_frame_equal (mc .weather , weather_expected )
354
358
# total_irrad attribute
355
359
assert_frame_equal (mc .total_irrad , total_irrad )
356
360
0 commit comments