Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address pandas FutureWarnings in test suite #1900

Merged
merged 9 commits into from
Nov 9, 2023
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/v0.10.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Contributors
* Miguel Sánchez de León Peque (:ghuser:`Peque`)
* Will Hobbs (:ghuser:`williamhobbs`)
* Anton Driesse (:ghuser:`adriesse`)
* :ghuser:`matsuobasho`
4 changes: 2 additions & 2 deletions pvlib/tests/iotools/test_srml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
5 changes: 3 additions & 2 deletions pvlib/tests/test_clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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[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
Expand Down
8 changes: 4 additions & 4 deletions pvlib/tests/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
22 changes: 11 additions & 11 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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', [
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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', [
Expand Down
7 changes: 3 additions & 4 deletions pvlib/tests/test_singlediode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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].applymap(
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].applymap(np.float64)
joined[is_number] = joined[is_number].astype(np.float64)

joined['Boltzmann'] = scipy.constants.Boltzmann
joined['Elementary Charge'] = scipy.constants.elementary_charge
Expand Down
Loading