Skip to content

Commit 4e55d50

Browse files
authored
Address pandas FutureWarnings in test suite (#1900)
* Cahnged expected reference in test_detect_clearskY_window to 1 from True to avoid Futurewarning * Change reference to etr in ibird function to avoid FutureWarning * In test_modelchain, update all instances when referring to series by position to using iloc to get rid of FutureWarning * Update to iloc method for referencing by position in test_irradiance to get rid of FutureWarning * In test_singlediode change applymap to map to get rid of FutureWarning * Test_srml update to select using iloc to get rid of FutureWarning * Substitute changing to float64 dtype using map with base functionality that's accessible across Pandas versions * Added username to Contributors * Update line break in test_clearsky to adhere to line length limit
1 parent 63a2ca4 commit 4e55d50

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

docs/sphinx/source/whatsnew/v0.10.3.rst

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ Contributors
3232
* Miguel Sánchez de León Peque (:ghuser:`Peque`)
3333
* Will Hobbs (:ghuser:`williamhobbs`)
3434
* Anton Driesse (:ghuser:`adriesse`)
35+
* :ghuser:`matsuobasho`

pvlib/tests/iotools/test_srml.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def test_read_srml_map_variables_false():
4242

4343
def test_read_srml_nans_exist():
4444
data = srml.read_srml(srml_testfile)
45-
assert isnan(data['dni_0'][1119])
46-
assert data['dni_0_flag'][1119] == 99
45+
assert isnan(data['dni_0'].iloc[1119])
46+
assert data['dni_0_flag'].iloc[1119] == 99
4747

4848

4949
@pytest.mark.parametrize('url,year,month', [

pvlib/tests/test_clearsky.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def test_detect_clearsky_window(detect_clearsky_data):
631631
clear_samples = clearsky.detect_clearsky(
632632
expected['GHI'], cs['ghi'], window_length=3)
633633
expected = expected['Clear or not'].copy()
634-
expected.iloc[-3:] = True
634+
expected.iloc[-3:] = 1
635635
assert_series_equal(expected, clear_samples,
636636
check_dtype=False, check_names=False)
637637

@@ -855,7 +855,8 @@ def test_bird():
855855
# test scalars just at noon
856856
# XXX: calculations start at 12am so noon is at index = 12
857857
irrads3 = clearsky.bird(
858-
zenith[12], airmass[12], aod_380nm, aod_500nm, h2o_cm, dni_extra=etr[12]
858+
zenith[12], airmass[12], aod_380nm, aod_500nm, h2o_cm,
859+
dni_extra=etr.iloc[12]
859860
)
860861
Eb3, Ebh3, Gh3, Dh3 = (irrads3[_] for _ in field_names)
861862
# XXX: testdata starts at 1am so noon is at index = 11

pvlib/tests/test_irradiance.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ def test_haydavies_components(irrad_data, ephem_data, dni_et):
237237
40, 180, irrad_data['dhi'].values[-1], irrad_data['dni'].values[-1],
238238
dni_et[-1], ephem_data['apparent_zenith'].values[-1],
239239
ephem_data['azimuth'].values[-1], return_components=True)
240-
assert_allclose(result['sky_diffuse'], expected['sky_diffuse'][-1],
240+
assert_allclose(result['sky_diffuse'], expected['sky_diffuse'].iloc[-1],
241241
atol=1e-4)
242-
assert_allclose(result['isotropic'], expected['isotropic'][-1],
242+
assert_allclose(result['isotropic'], expected['isotropic'].iloc[-1],
243243
atol=1e-4)
244-
assert_allclose(result['circumsolar'], expected['circumsolar'][-1],
244+
assert_allclose(result['circumsolar'], expected['circumsolar'].iloc[-1],
245245
atol=1e-4)
246-
assert_allclose(result['horizon'], expected['horizon'][-1], atol=1e-4)
246+
assert_allclose(result['horizon'], expected['horizon'].iloc[-1], atol=1e-4)
247247
assert isinstance(result, dict)
248248

249249

pvlib/tests/test_modelchain.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ def test_ac_models(sapm_dc_snl_ac_system, cec_dc_adr_ac_system,
13731373
assert m.call_count == 1
13741374
assert isinstance(mc.results.ac, pd.Series)
13751375
assert not mc.results.ac.empty
1376-
assert mc.results.ac[1] < 1
1376+
assert mc.results.ac.iloc[1] < 1
13771377

13781378

13791379
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,
14251425
assert m.call_count == 1
14261426
assert isinstance(mc.results.ac, pd.Series)
14271427
assert not mc.results.ac.empty
1428-
assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200
1429-
assert mc.results.ac[1] < 1
1428+
assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200
1429+
assert mc.results.ac.iloc[1] < 1
14301430

14311431

14321432
@pytest.mark.parametrize('aoi_model', [
@@ -1441,8 +1441,8 @@ def test_aoi_models_singleon_weather_single_array(
14411441
assert len(mc.results.aoi_modifier) == 1
14421442
assert isinstance(mc.results.ac, pd.Series)
14431443
assert not mc.results.ac.empty
1444-
assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200
1445-
assert mc.results.ac[1] < 1
1444+
assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200
1445+
assert mc.results.ac.iloc[1] < 1
14461446

14471447

14481448
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):
14511451
mc.run_model(weather)
14521452
assert mc.results.aoi_modifier == 1.0
14531453
assert not mc.results.ac.empty
1454-
assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200
1455-
assert mc.results.ac[1] < 1
1454+
assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200
1455+
assert mc.results.ac.iloc[1] < 1
14561456

14571457

14581458
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):
14721472
assert m.call_args[1]['theta_ref'] == theta_ref
14731473
assert isinstance(mc.results.ac, pd.Series)
14741474
assert not mc.results.ac.empty
1475-
assert mc.results.ac[0] > 150 and mc.results.ac[0] < 200
1476-
assert mc.results.ac[1] < 1
1475+
assert mc.results.ac.iloc[0] > 150 and mc.results.ac.iloc[0] < 200
1476+
assert mc.results.ac.iloc[1] < 1
14771477

14781478

14791479
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):
14841484
assert m.call_count == 1
14851485
assert mc.results.aoi_modifier == 0.9
14861486
assert not mc.results.ac.empty
1487-
assert mc.results.ac[0] > 140 and mc.results.ac[0] < 200
1488-
assert mc.results.ac[1] < 1
1487+
assert mc.results.ac.iloc[0] > 140 and mc.results.ac.iloc[0] < 200
1488+
assert mc.results.ac.iloc[1] < 1
14891489

14901490

14911491
@pytest.mark.parametrize('aoi_model', [

pvlib/tests/test_singlediode.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,11 @@ def build_precise_iv_curve_dataframe(file_csv, file_json):
110110

111111
# parse strings to np.float64
112112
is_array = ['Currents', 'Voltages', 'diode_voltage']
113-
joined[is_array] = joined[is_array].applymap(
114-
lambda a: np.asarray(a, dtype=np.float64)
115-
)
113+
for col in is_array:
114+
joined[col] = [np.asarray(a, dtype=np.float64) for a in joined[col]]
116115
is_number = ['v_oc', 'i_sc', 'v_mp', 'i_mp', 'p_mp', 'i_x', 'i_xx',
117116
'Temperature']
118-
joined[is_number] = joined[is_number].applymap(np.float64)
117+
joined[is_number] = joined[is_number].astype(np.float64)
119118

120119
joined['Boltzmann'] = scipy.constants.Boltzmann
121120
joined['Elementary Charge'] = scipy.constants.elementary_charge

0 commit comments

Comments
 (0)