def test_read_pvgis_tmy_epw(expected, epw_meta): fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.epw' # infer outputformat from file extensions pvgis_data = read_pvgis_tmy(fn) _compare_pvgis_tmy_epw(expected, epw_meta, pvgis_data) # explicit pvgis outputformat pvgis_data = read_pvgis_tmy(fn, pvgis_format='epw') _compare_pvgis_tmy_epw(expected, epw_meta, pvgis_data) with fn.open('r') as fbuf: pvgis_data = read_pvgis_tmy(fbuf, pvgis_format='epw') _compare_pvgis_tmy_epw(expected, epw_meta, pvgis_data)
def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected, meta_expected, csv_meta): fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.csv' # infer outputformat from file extensions pvgis_data = read_pvgis_tmy(fn) _compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected, meta_expected, csv_meta, pvgis_data) # explicit pvgis outputformat pvgis_data = read_pvgis_tmy(fn, pvgis_format='csv') _compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected, meta_expected, csv_meta, pvgis_data) with fn.open('rb') as fbuf: pvgis_data = read_pvgis_tmy(fbuf, pvgis_format='csv') _compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected, meta_expected, csv_meta, pvgis_data)
def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected, meta_expected): fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.json' # infer outputformat from file extensions pvgis_data = read_pvgis_tmy(fn, map_variables=False) _compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected, meta_expected, pvgis_data) # explicit pvgis outputformat pvgis_data = read_pvgis_tmy(fn, pvgis_format='json', map_variables=False) _compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected, meta_expected, pvgis_data) with fn.open('r') as fbuf: pvgis_data = read_pvgis_tmy(fbuf, pvgis_format='json', map_variables=False) _compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected, meta_expected, pvgis_data)
def test_read_pvgis_tmy_basic(expected, meta_expected): fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.txt' # XXX: can't infer outputformat from file extensions for basic with pytest.raises(ValueError, match="pvgis format 'txt' was unknown"): read_pvgis_tmy(fn) # explicit pvgis outputformat pvgis_data = read_pvgis_tmy(fn, pvgis_format='basic') _compare_pvgis_tmy_basic(expected, meta_expected, pvgis_data) with fn.open('rb') as fbuf: pvgis_data = read_pvgis_tmy(fbuf, pvgis_format='basic') _compare_pvgis_tmy_basic(expected, meta_expected, pvgis_data) # file buffer raises TypeError if passed to pathlib.Path() with pytest.raises(TypeError): read_pvgis_tmy(fbuf)
def test_read_pvgis_tmy_exception(): bad_outputformat = 'bad' err_msg = "pvgis format '{:s}' was unknown".format(bad_outputformat) with pytest.raises(ValueError, match=err_msg): read_pvgis_tmy('filename', pvgis_format=bad_outputformat)
def test_read_pvgis_tmy_exception(): bad_outputformat = 'bad' err_msg = f"pvgis format '{bad_outputformat:s}' was unknown" with pytest.raises(ValueError, match=err_msg): read_pvgis_tmy('filename', pvgis_format=bad_outputformat, map_variables=False)
def test_read_pvgis_tmy_map_variables(pvgis_tmy_mapped_columns): fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.json' actual, _, _, _ = read_pvgis_tmy(fn, map_variables=True) assert all([c in pvgis_tmy_mapped_columns for c in actual.columns])
def test_pvgis_tmy_variable_map_deprecating_warning_0_10(): with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'): _ = get_pvgis_tmy(45, 8) with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'): fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.epw' _ = read_pvgis_tmy(fn)