@@ -371,9 +371,7 @@ def meta_expected():
371371
372372@pytest .fixture
373373def csv_meta (meta_expected ):
374- return [
375- f"{ k } : { v ['description' ]} ({ v ['units' ]} )" for k , v
376- in meta_expected ['outputs' ]['tmy_hourly' ]['variables' ].items ()]
374+ return meta_expected ['outputs' ]['tmy_hourly' ]['variables' ]
377375
378376
379377@pytest .fixture
@@ -393,7 +391,15 @@ def test_get_pvgis_tmy(expected, month_year_expected, inputs_expected,
393391
394392def _compare_pvgis_tmy_json (expected , month_year_expected , inputs_expected ,
395393 meta_expected , pvgis_data ):
396- data , months_selected , inputs , meta = pvgis_data
394+ data , meta = pvgis_data
395+
396+ # Re-create original outputs (prior to #2470)
397+ months_selected = meta ['months_selected' ]
398+ inputs = meta ['inputs' ].copy ()
399+ del inputs ['descriptions' ]
400+ meta ['inputs' ] = meta ['inputs' ]['descriptions' ]
401+ del meta ['months_selected' ]
402+
397403 # check each column of output separately
398404 for outvar in meta_expected ['outputs' ]['tmy_hourly' ]['variables' ].keys ():
399405 assert np .allclose (data [outvar ], expected [outvar ])
@@ -419,21 +425,20 @@ def _compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
419425@pytest .mark .remote_data
420426@pytest .mark .flaky (reruns = RERUNS , reruns_delay = RERUNS_DELAY )
421427def test_get_pvgis_tmy_kwargs (userhorizon_expected ):
422- _ , _ , inputs , _ = get_pvgis_tmy (45 , 8 , usehorizon = False ,
423- map_variables = False )
424- assert inputs ['meteo_data' ]['use_horizon' ] is False
425- data , _ , _ , _ = get_pvgis_tmy (
428+ _ , meta = get_pvgis_tmy (45 , 8 , usehorizon = False , map_variables = False )
429+ assert meta ['inputs' ]['meteo_data' ]['use_horizon' ] is False
430+ data , _ = get_pvgis_tmy (
426431 45 , 8 , userhorizon = [0 , 10 , 20 , 30 , 40 , 15 , 25 , 5 ], map_variables = False )
427432 assert np .allclose (
428433 data ['G(h)' ], userhorizon_expected ['G(h)' ].values )
429434 assert np .allclose (
430435 data ['Gb(n)' ], userhorizon_expected ['Gb(n)' ].values )
431436 assert np .allclose (
432437 data ['Gd(h)' ], userhorizon_expected ['Gd(h)' ].values )
433- _ , _ , inputs , _ = get_pvgis_tmy (45 , 8 , startyear = 2005 , map_variables = False )
434- assert inputs ['meteo_data' ]['year_min' ] == 2005
435- _ , _ , inputs , _ = get_pvgis_tmy (45 , 8 , endyear = 2016 , map_variables = False )
436- assert inputs ['meteo_data' ]['year_max' ] == 2016
438+ _ , meta = get_pvgis_tmy (45 , 8 , startyear = 2005 , map_variables = False )
439+ assert meta [ ' inputs' ] ['meteo_data' ]['year_min' ] == 2005
440+ _ , meta = get_pvgis_tmy (45 , 8 , endyear = 2016 , map_variables = False )
441+ assert meta [ ' inputs' ] ['meteo_data' ]['year_max' ] == 2016
437442
438443
439444@pytest .mark .remote_data
@@ -450,8 +455,8 @@ def test_get_pvgis_tmy_coerce_year():
450455 cet_name = 'Etc/GMT-1'
451456 # check indices of rolled data after converting timezone
452457 pvgis_data , _ = get_pvgis_tmy (45 , 8 , roll_utc_offset = cet_tz )
453- jan1_midnight = pd .Timestamp ('1990-01-01 00:00:00 ' , tz = cet_name )
454- dec31_midnight = pd .Timestamp ('1990-12-31 23:00:00 ' , tz = cet_name )
458+ jan1_midnight = pd .Timestamp ('1990-01-01 00' , tz = cet_name )
459+ dec31_midnight = pd .Timestamp ('1990-12-31 23' , tz = cet_name )
455460 assert pvgis_data .index [0 ] == jan1_midnight
456461 assert pvgis_data .index [- 1 ] == dec31_midnight
457462 assert pvgis_data .index .name == f'time({ cet_name } )'
@@ -463,8 +468,8 @@ def test_get_pvgis_tmy_coerce_year():
463468 test_yr = 2021
464469 pvgis_data , _ = get_pvgis_tmy (
465470 45 , 8 , roll_utc_offset = cet_tz , coerce_year = test_yr )
466- jan1_midnight = pd .Timestamp (f'{ test_yr } -01-01 00:00:00 ' , tz = cet_name )
467- dec31_midnight = pd .Timestamp (f'{ test_yr } -12-31 23:00:00 ' , tz = cet_name )
471+ jan1_midnight = pd .Timestamp (f'{ test_yr } -01-01 00' , tz = cet_name )
472+ dec31_midnight = pd .Timestamp (f'{ test_yr } -12-31 23' , tz = cet_name )
468473 assert pvgis_data .index [0 ] == jan1_midnight
469474 assert pvgis_data .index [- 1 ] == dec31_midnight
470475 assert pvgis_data .index .name == f'time({ cet_name } )'
@@ -473,8 +478,8 @@ def test_get_pvgis_tmy_coerce_year():
473478 assert all (test_case == expected )
474479 # repeat tests with year coerced but utc offset none or zero
475480 pvgis_data , _ = get_pvgis_tmy (45 , 8 , coerce_year = test_yr )
476- jan1_midnight = pd .Timestamp (f'{ test_yr } -01-01 00:00:00 ' , tz = 'UTC' )
477- dec31_midnight = pd .Timestamp (f'{ test_yr } -12-31 23:00:00 ' , tz = 'UTC' )
481+ jan1_midnight = pd .Timestamp (f'{ test_yr } -01-01 00' , tz = 'UTC' )
482+ dec31_midnight = pd .Timestamp (f'{ test_yr } -12-31 23' , tz = 'UTC' )
478483 assert pvgis_data .index [0 ] == jan1_midnight
479484 assert pvgis_data .index [- 1 ] == dec31_midnight
480485 assert pvgis_data .index .name == 'time(UTC)'
@@ -494,7 +499,13 @@ def test_get_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
494499
495500def _compare_pvgis_tmy_csv (expected , month_year_expected , inputs_expected ,
496501 meta_expected , csv_meta , pvgis_data ):
497- data , months_selected , inputs , meta = pvgis_data
502+ data , meta = pvgis_data
503+
504+ # Re-create original outputs (prior to #2470)
505+ months_selected = meta ['months_selected' ]
506+ inputs = meta ['inputs' ].copy ()
507+ meta = meta ['descriptions' ]
508+
498509 # check each column of output separately
499510 for outvar in meta_expected ['outputs' ]['tmy_hourly' ]['variables' ].keys ():
500511 assert np .allclose (data [outvar ], expected [outvar ])
@@ -526,7 +537,7 @@ def test_get_pvgis_tmy_epw(expected, epw_meta):
526537
527538
528539def _compare_pvgis_tmy_epw (expected , epw_meta , pvgis_data ):
529- data , _ , _ , meta = pvgis_data
540+ data , meta = pvgis_data
530541 assert np .allclose (data .ghi , expected ['G(h)' ])
531542 assert np .allclose (data .dni , expected ['Gb(n)' ])
532543 assert np .allclose (data .dhi , expected ['Gd(h)' ])
0 commit comments