@@ -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,28 +425,27 @@ 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
440445@pytest .mark .flaky (reruns = RERUNS , reruns_delay = RERUNS_DELAY )
441446def test_get_pvgis_tmy_coerce_year ():
442447 """test utc_offset and coerce_year work as expected"""
443- base_case , _ , _ , _ = get_pvgis_tmy (45 , 8 ) # Turin
448+ base_case , _ = get_pvgis_tmy (45 , 8 ) # Turin
444449 assert str (base_case .index .tz ) == 'UTC'
445450 assert base_case .index .name == 'time(UTC)'
446451 noon_test_data = [
@@ -449,9 +454,9 @@ def test_get_pvgis_tmy_coerce_year():
449454 cet_tz = 1 # Turin time is CET
450455 cet_name = 'Etc/GMT-1'
451456 # check indices of rolled data after converting timezone
452- 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 )
457+ pvgis_data , _ = get_pvgis_tmy (45 , 8 , roll_utc_offset = cet_tz )
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 } )'
@@ -461,20 +466,20 @@ def test_get_pvgis_tmy_coerce_year():
461466 assert all (test_case == expected )
462467 # repeat tests with year coerced
463468 test_yr = 2021
464- pvgis_data , _ , _ , _ = get_pvgis_tmy (
469+ 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 } )'
471476 for m , test_case in enumerate (noon_test_data ):
472477 expected = pvgis_data [pvgis_data .index .month == m + 1 ].iloc [12 + cet_tz ]
473478 assert all (test_case == expected )
474479 # repeat tests with year coerced but utc offset none or zero
475- 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' )
480+ pvgis_data , _ = get_pvgis_tmy (45 , 8 , coerce_year = test_yr )
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)' ])
@@ -556,8 +567,8 @@ def test_get_pvgis_tmy_basic():
556567
557568@pytest .mark .remote_data
558569@pytest .mark .flaky (reruns = RERUNS , reruns_delay = RERUNS_DELAY )
559- def test_get_pvgis_map_variables (pvgis_tmy_mapped_columns ):
560- actual , _ , _ , _ = get_pvgis_tmy (45 , 8 , map_variables = True )
570+ def test_get_pvgis_tmy_map_variables (pvgis_tmy_mapped_columns ):
571+ actual , _ = get_pvgis_tmy (45 , 8 , map_variables = True )
561572 assert all (c in pvgis_tmy_mapped_columns for c in actual .columns )
562573
563574
@@ -580,7 +591,7 @@ def test_read_pvgis_horizon_invalid_coords():
580591
581592def test_read_pvgis_tmy_map_variables (pvgis_tmy_mapped_columns ):
582593 fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.json'
583- actual , _ , _ , _ = read_pvgis_tmy (fn , map_variables = True )
594+ actual , _ = read_pvgis_tmy (fn , map_variables = True )
584595 assert all (c in pvgis_tmy_mapped_columns for c in actual .columns )
585596
586597
0 commit comments