From 0ed672e9babc0774546e25facbd4201503dd59a9 Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Sun, 29 Oct 2023 17:52:11 -0400 Subject: [PATCH 1/9] Cahnged expected reference in test_detect_clearskY_window to 1 from True to avoid Futurewarning --- pvlib/tests/test_clearsky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_clearsky.py b/pvlib/tests/test_clearsky.py index c2ef607f0f..5e80a2cf12 100644 --- a/pvlib/tests/test_clearsky.py +++ b/pvlib/tests/test_clearsky.py @@ -631,7 +631,7 @@ def test_detect_clearsky_window(detect_clearsky_data): clear_samples = clearsky.detect_clearsky( expected['GHI'], cs['ghi'], window_length=3) expected = expected['Clear or not'].copy() - expected.iloc[-3:] = True + expected.iloc[-3:] = 1 assert_series_equal(expected, clear_samples, check_dtype=False, check_names=False) From 8ed03ddca14550a7f897322fd34967d50b2686b5 Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Sun, 29 Oct 2023 17:53:29 -0400 Subject: [PATCH 2/9] Change reference to etr in ibird function to avoid FutureWarning --- pvlib/tests/test_clearsky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_clearsky.py b/pvlib/tests/test_clearsky.py index 5e80a2cf12..8e9917b700 100644 --- a/pvlib/tests/test_clearsky.py +++ b/pvlib/tests/test_clearsky.py @@ -855,7 +855,7 @@ def test_bird(): # test scalars just at noon # XXX: calculations start at 12am so noon is at index = 12 irrads3 = clearsky.bird( - zenith[12], airmass[12], aod_380nm, aod_500nm, h2o_cm, dni_extra=etr[12] + zenith[12], airmass[12], aod_380nm, aod_500nm, h2o_cm, dni_extra=etr.iloc[12] ) Eb3, Ebh3, Gh3, Dh3 = (irrads3[_] for _ in field_names) # XXX: testdata starts at 1am so noon is at index = 11 From e9ae1cdcb779b1588dd6b2b10686b90a62bc8e61 Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Sun, 29 Oct 2023 18:02:51 -0400 Subject: [PATCH 3/9] In test_modelchain, update all instances when referring to series by position to using iloc to get rid of FutureWarning --- pvlib/tests/test_modelchain.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py index d9dfc7bd64..c59a02e9c4 100644 --- a/pvlib/tests/test_modelchain.py +++ b/pvlib/tests/test_modelchain.py @@ -1373,7 +1373,7 @@ def test_ac_models(sapm_dc_snl_ac_system, cec_dc_adr_ac_system, assert m.call_count == 1 assert isinstance(mc.results.ac, pd.Series) assert not mc.results.ac.empty - assert mc.results.ac[1] < 1 + assert mc.results.ac.iloc[1] < 1 def test_ac_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather, @@ -1425,8 +1425,8 @@ def test_aoi_models(sapm_dc_snl_ac_system, location, aoi_model, assert m.call_count == 1 assert isinstance(mc.results.ac, pd.Series) assert not mc.results.ac.empty - assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200 - assert mc.results.ac[1] < 1 + assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200 + assert mc.results.ac.iloc[1] < 1 @pytest.mark.parametrize('aoi_model', [ @@ -1441,8 +1441,8 @@ def test_aoi_models_singleon_weather_single_array( assert len(mc.results.aoi_modifier) == 1 assert isinstance(mc.results.ac, pd.Series) assert not mc.results.ac.empty - assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200 - assert mc.results.ac[1] < 1 + assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200 + assert mc.results.ac.iloc[1] < 1 def test_aoi_model_no_loss(sapm_dc_snl_ac_system, location, weather): @@ -1451,8 +1451,8 @@ def test_aoi_model_no_loss(sapm_dc_snl_ac_system, location, weather): mc.run_model(weather) assert mc.results.aoi_modifier == 1.0 assert not mc.results.ac.empty - assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200 - assert mc.results.ac[1] < 1 + assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200 + assert mc.results.ac.iloc[1] < 1 def test_aoi_model_interp(sapm_dc_snl_ac_system, location, weather, mocker): @@ -1472,8 +1472,8 @@ def test_aoi_model_interp(sapm_dc_snl_ac_system, location, weather, mocker): assert m.call_args[1]['theta_ref'] == theta_ref assert isinstance(mc.results.ac, pd.Series) assert not mc.results.ac.empty - assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200 - assert mc.results.ac[1] < 1 + assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200 + assert mc.results.ac.iloc[1] < 1 def test_aoi_model_user_func(sapm_dc_snl_ac_system, location, weather, mocker): @@ -1484,8 +1484,8 @@ def test_aoi_model_user_func(sapm_dc_snl_ac_system, location, weather, mocker): assert m.call_count == 1 assert mc.results.aoi_modifier == 0.9 assert not mc.results.ac.empty - assert mc.results.ac[0] > 140 and mc.results.ac[0] < 200 - assert mc.results.ac[1] < 1 + assert mc.results.ac.iloc[0] > 140 and mc.results.ac.iloc[0] < 200 + assert mc.results.ac.iloc[1] < 1 @pytest.mark.parametrize('aoi_model', [ From 12746bb2722e4f1028142d3a14ff028ae9379457 Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Sun, 29 Oct 2023 18:09:43 -0400 Subject: [PATCH 4/9] Update to iloc method for referencing by position in test_irradiance to get rid of FutureWarning --- pvlib/tests/test_irradiance.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_irradiance.py b/pvlib/tests/test_irradiance.py index 8f24e7a605..ba66f4dc36 100644 --- a/pvlib/tests/test_irradiance.py +++ b/pvlib/tests/test_irradiance.py @@ -237,13 +237,13 @@ def test_haydavies_components(irrad_data, ephem_data, dni_et): 40, 180, irrad_data['dhi'].values[-1], irrad_data['dni'].values[-1], dni_et[-1], ephem_data['apparent_zenith'].values[-1], ephem_data['azimuth'].values[-1], return_components=True) - assert_allclose(result['sky_diffuse'], expected['sky_diffuse'][-1], + assert_allclose(result['sky_diffuse'], expected['sky_diffuse'].iloc[-1], atol=1e-4) - assert_allclose(result['isotropic'], expected['isotropic'][-1], + assert_allclose(result['isotropic'], expected['isotropic'].iloc[-1], atol=1e-4) - assert_allclose(result['circumsolar'], expected['circumsolar'][-1], + assert_allclose(result['circumsolar'], expected['circumsolar'].iloc[-1], atol=1e-4) - assert_allclose(result['horizon'], expected['horizon'][-1], atol=1e-4) + assert_allclose(result['horizon'], expected['horizon'].iloc[-1], atol=1e-4) assert isinstance(result, dict) From 538f9c34833d75f740f4f4bac8484d912106097a Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Sun, 29 Oct 2023 18:13:25 -0400 Subject: [PATCH 5/9] In test_singlediode change applymap to map to get rid of FutureWarning --- pvlib/tests/test_singlediode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/test_singlediode.py b/pvlib/tests/test_singlediode.py index 8e0d05668e..38b35b1895 100644 --- a/pvlib/tests/test_singlediode.py +++ b/pvlib/tests/test_singlediode.py @@ -110,12 +110,12 @@ def build_precise_iv_curve_dataframe(file_csv, file_json): # parse strings to np.float64 is_array = ['Currents', 'Voltages', 'diode_voltage'] - joined[is_array] = joined[is_array].applymap( + joined[is_array] = joined[is_array].map( lambda a: np.asarray(a, dtype=np.float64) ) is_number = ['v_oc', 'i_sc', 'v_mp', 'i_mp', 'p_mp', 'i_x', 'i_xx', 'Temperature'] - joined[is_number] = joined[is_number].applymap(np.float64) + joined[is_number] = joined[is_number].map(np.float64) joined['Boltzmann'] = scipy.constants.Boltzmann joined['Elementary Charge'] = scipy.constants.elementary_charge From 69b3bc2eea8612ac6edf10d5316ea723d838e204 Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Sun, 29 Oct 2023 19:04:05 -0400 Subject: [PATCH 6/9] Test_srml update to select using iloc to get rid of FutureWarning --- pvlib/tests/iotools/test_srml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/iotools/test_srml.py b/pvlib/tests/iotools/test_srml.py index 330b1313f8..7e586dd9b3 100644 --- a/pvlib/tests/iotools/test_srml.py +++ b/pvlib/tests/iotools/test_srml.py @@ -42,8 +42,8 @@ def test_read_srml_map_variables_false(): def test_read_srml_nans_exist(): data = srml.read_srml(srml_testfile) - assert isnan(data['dni_0'][1119]) - assert data['dni_0_flag'][1119] == 99 + assert isnan(data['dni_0'].iloc[1119]) + assert data['dni_0_flag'].iloc[1119] == 99 @pytest.mark.parametrize('url,year,month', [ From 64c321776a735411b47942211a9457195a57844a Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Mon, 6 Nov 2023 15:27:55 -0500 Subject: [PATCH 7/9] Substitute changing to float64 dtype using map with base functionality that's accessible across Pandas versions --- pvlib/tests/test_singlediode.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_singlediode.py b/pvlib/tests/test_singlediode.py index 38b35b1895..899f158415 100644 --- a/pvlib/tests/test_singlediode.py +++ b/pvlib/tests/test_singlediode.py @@ -110,12 +110,11 @@ def build_precise_iv_curve_dataframe(file_csv, file_json): # parse strings to np.float64 is_array = ['Currents', 'Voltages', 'diode_voltage'] - joined[is_array] = joined[is_array].map( - lambda a: np.asarray(a, dtype=np.float64) - ) + for col in is_array: + joined[col] = [np.asarray(a, dtype=np.float64) for a in joined[col]] is_number = ['v_oc', 'i_sc', 'v_mp', 'i_mp', 'p_mp', 'i_x', 'i_xx', 'Temperature'] - joined[is_number] = joined[is_number].map(np.float64) + joined[is_number] = joined[is_number].astype(np.float64) joined['Boltzmann'] = scipy.constants.Boltzmann joined['Elementary Charge'] = scipy.constants.elementary_charge From d8614a1beadcac3d13128812e9ce16e0b81b9646 Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Mon, 6 Nov 2023 15:36:17 -0500 Subject: [PATCH 8/9] Added username to Contributors --- docs/sphinx/source/whatsnew/v0.10.3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/whatsnew/v0.10.3.rst b/docs/sphinx/source/whatsnew/v0.10.3.rst index 8bdc2cf98f..b7eece4108 100644 --- a/docs/sphinx/source/whatsnew/v0.10.3.rst +++ b/docs/sphinx/source/whatsnew/v0.10.3.rst @@ -32,3 +32,4 @@ Contributors * Miguel Sánchez de León Peque (:ghuser:`Peque`) * Will Hobbs (:ghuser:`williamhobbs`) * Anton Driesse (:ghuser:`adriesse`) +* :ghuser:`matsuobasho` From 8cfcedc21745efa5e1598b01d9570714e62e113d Mon Sep 17 00:00:00 2001 From: Roma Koulikov Date: Mon, 6 Nov 2023 15:43:29 -0500 Subject: [PATCH 9/9] Update line break in test_clearsky to adhere to line length limit --- pvlib/tests/test_clearsky.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/test_clearsky.py b/pvlib/tests/test_clearsky.py index 8e9917b700..fa4dee2cd0 100644 --- a/pvlib/tests/test_clearsky.py +++ b/pvlib/tests/test_clearsky.py @@ -855,7 +855,8 @@ def test_bird(): # test scalars just at noon # XXX: calculations start at 12am so noon is at index = 12 irrads3 = clearsky.bird( - zenith[12], airmass[12], aod_380nm, aod_500nm, h2o_cm, dni_extra=etr.iloc[12] + zenith[12], airmass[12], aod_380nm, aod_500nm, h2o_cm, + dni_extra=etr.iloc[12] ) Eb3, Ebh3, Gh3, Dh3 = (irrads3[_] for _ in field_names) # XXX: testdata starts at 1am so noon is at index = 11