diff --git a/ci/requirements-py3.10.yml b/ci/requirements-py3.10.yml index 08552ec3cd..cc11e4cb8a 100644 --- a/ci/requirements-py3.10.yml +++ b/ci/requirements-py3.10.yml @@ -17,7 +17,7 @@ dependencies: - requests-mock - pytest-timeout - pytest-rerunfailures - - pytest-remotedata + - conda-forge::pytest-remotedata # version in default channel is old - python=3.10 - pytz - requests diff --git a/ci/requirements-py3.11.yml b/ci/requirements-py3.11.yml index 2bbd0112b5..5bd43c6df7 100644 --- a/ci/requirements-py3.11.yml +++ b/ci/requirements-py3.11.yml @@ -17,7 +17,7 @@ dependencies: - requests-mock - pytest-timeout - pytest-rerunfailures - - pytest-remotedata + - conda-forge::pytest-remotedata # version in default channel is old - python=3.11 - pytz - requests diff --git a/ci/requirements-py3.12.yml b/ci/requirements-py3.12.yml index 69632b3ac1..5e65c3ed6f 100644 --- a/ci/requirements-py3.12.yml +++ b/ci/requirements-py3.12.yml @@ -17,7 +17,7 @@ dependencies: - requests-mock - pytest-timeout - pytest-rerunfailures - - pytest-remotedata + - conda-forge::pytest-remotedata # version in default channel is old - python=3.12 - pytz - requests diff --git a/ci/requirements-py3.7.yml b/ci/requirements-py3.7.yml index 5f1983eada..49da67f3de 100644 --- a/ci/requirements-py3.7.yml +++ b/ci/requirements-py3.7.yml @@ -17,7 +17,7 @@ dependencies: - requests-mock - pytest-timeout - pytest-rerunfailures - - pytest-remotedata + - conda-forge::pytest-remotedata # version in default channel is old - python=3.7 - pytz - requests diff --git a/ci/requirements-py3.8.yml b/ci/requirements-py3.8.yml index e316188bb7..0f5d63fd4a 100644 --- a/ci/requirements-py3.8.yml +++ b/ci/requirements-py3.8.yml @@ -17,7 +17,7 @@ dependencies: - requests-mock - pytest-timeout - pytest-rerunfailures - - pytest-remotedata + - conda-forge::pytest-remotedata # version in default channel is old - python=3.8 - pytz - requests diff --git a/ci/requirements-py3.9.yml b/ci/requirements-py3.9.yml index 3415560e06..14151ce47a 100644 --- a/ci/requirements-py3.9.yml +++ b/ci/requirements-py3.9.yml @@ -17,7 +17,7 @@ dependencies: - requests-mock - pytest-timeout - pytest-rerunfailures - - pytest-remotedata + - conda-forge::pytest-remotedata # version in default channel is old - python=3.9 - pytz - requests diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index c9ed8394cd..43fdbe919f 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -321,7 +321,7 @@ def parse_bsrn(fbuf, logical_records=('0100',)): LR_0100.columns = BSRN_LR0100_COLUMNS # Set datetime index LR_0100.index = (start_date+pd.to_timedelta(LR_0100['day']-1, unit='d') - + pd.to_timedelta(LR_0100['minute'], unit='T')) + + pd.to_timedelta(LR_0100['minute'], unit='minutes')) # Drop empty, minute, and day columns LR_0100 = LR_0100.drop(columns=['empty', 'day', 'minute']) dfs.append(LR_0100) @@ -335,7 +335,7 @@ def parse_bsrn(fbuf, logical_records=('0100',)): colspecs=BSRN_LR0300_COL_SPECS, names=BSRN_LR0300_COLUMNS) LR_0300.index = (start_date+pd.to_timedelta(LR_0300['day']-1, unit='d') - + pd.to_timedelta(LR_0300['minute'], unit='T')) + + pd.to_timedelta(LR_0300['minute'], unit='minutes')) LR_0300 = LR_0300.drop(columns=['day', 'minute']).astype(float) dfs.append(LR_0300) @@ -352,7 +352,7 @@ def parse_bsrn(fbuf, logical_records=('0100',)): LR_0500 = LR_0500.reindex(sorted(LR_0500.columns), axis='columns') LR_0500.columns = BSRN_LR0500_COLUMNS LR_0500.index = (start_date+pd.to_timedelta(LR_0500['day']-1, unit='d') - + pd.to_timedelta(LR_0500['minute'], unit='T')) + + pd.to_timedelta(LR_0500['minute'], unit='minutes')) LR_0500 = LR_0500.drop(columns=['empty', 'day', 'minute']) dfs.append(LR_0500) diff --git a/pvlib/ivtools/sdm.py b/pvlib/ivtools/sdm.py index 7d5a1cdd79..07bd6e2396 100644 --- a/pvlib/ivtools/sdm.py +++ b/pvlib/ivtools/sdm.py @@ -680,7 +680,7 @@ def _fit_desoto_sandia_diode(ee, voc, vth, tc, specs, const): y = voc - specs['beta_voc'] * (tc - const['T0']) new_x = sm.add_constant(x) res = sm.RLM(y, new_x).fit() - return res.params[1] + return np.array(res.params)[1] def _initial_iv_params(ivcurves, ee, voc, isc, rsh, nnsvth): diff --git a/pvlib/scaling.py b/pvlib/scaling.py index 7fbc0a46d1..207b60571e 100644 --- a/pvlib/scaling.py +++ b/pvlib/scaling.py @@ -134,6 +134,7 @@ def fn(x): return np.abs((x ** 2 - x) / 2 - n_pairs) n_dist = np.round(scipy.optimize.fmin(fn, np.sqrt(n_pairs), disp=False)) + n_dist = n_dist.item() # Compute VR A = cloud_speed / 2 # Resultant fit for A from [2] vr = np.zeros(tmscales.shape) @@ -276,7 +277,7 @@ def _compute_wavelet(clearsky_index, dt=None): # Produces slightly different end effects than the MATLAB version df = cs_long.rolling(window=intvlen, center=True, min_periods=1).mean() # Fill nan's in both directions - df = df.fillna(method='bfill').fillna(method='ffill') + df = df.bfill().ffill() # Pop values back out of the dataframe and store csi_mean[i, :] = df.values.flatten() # Shift to account for different indexing in MATLAB moving average diff --git a/pvlib/snow.py b/pvlib/snow.py index b245c21945..1f8704fe5e 100644 --- a/pvlib/snow.py +++ b/pvlib/snow.py @@ -53,9 +53,9 @@ def fully_covered_nrel(snowfall, threshold_snowfall=1.): freq = pd.infer_freq(snowfall.index) if freq is not None: timedelta = pd.tseries.frequencies.to_offset(freq) / pd.Timedelta('1h') - hourly_snow_rate.iloc[0] = snowfall[0] / timedelta + hourly_snow_rate.iloc[0] = snowfall.iloc[0] / timedelta else: # can't infer frequency from index - hourly_snow_rate[0] = 0 # replaces NaN + hourly_snow_rate.iloc[0] = 0 # replaces NaN return hourly_snow_rate > threshold_snowfall diff --git a/pvlib/soiling.py b/pvlib/soiling.py index bcdaf97b58..6f81d76f0e 100644 --- a/pvlib/soiling.py +++ b/pvlib/soiling.py @@ -91,7 +91,7 @@ def hsu(rainfall, cleaning_threshold, surface_tilt, pm2_5, pm10, mass_no_cleaning = pd.Series(index=rainfall.index, data=tms_cumsum) # specify dtype so pandas doesn't assume object mass_removed = pd.Series(index=rainfall.index, dtype='float64') - mass_removed[0] = 0. + mass_removed.iloc[0] = 0. mass_removed[cleaning_times] = mass_no_cleaning[cleaning_times] accum_mass = mass_no_cleaning - mass_removed.ffill() diff --git a/pvlib/solarposition.py b/pvlib/solarposition.py index 38ffa9e51c..7d378bc29a 100644 --- a/pvlib/solarposition.py +++ b/pvlib/solarposition.py @@ -832,7 +832,7 @@ def ephemeris(time, latitude, longitude, pressure=101325, temperature=12): # Calculate refraction correction Elevation = SunEl TanEl = pd.Series(np.tan(np.radians(Elevation)), index=time_utc) - Refract = pd.Series(0, index=time_utc) + Refract = pd.Series(0., index=time_utc) Refract[(Elevation > 5) & (Elevation <= 85)] = ( 58.1/TanEl - 0.07/(TanEl**3) + 8.6e-05/(TanEl**5)) diff --git a/pvlib/tests/bifacial/test_utils.py b/pvlib/tests/bifacial/test_utils.py index cb49c39efa..12894f72b1 100644 --- a/pvlib/tests/bifacial/test_utils.py +++ b/pvlib/tests/bifacial/test_utils.py @@ -120,13 +120,15 @@ def test_vf_row_sky_2d(test_system_fixed_tilt): def test_vf_row_sky_2d_integ(test_system_fixed_tilt): ts, _, _ = test_system_fixed_tilt # with float input, check end position - vf = utils.vf_row_sky_2d_integ(ts['surface_tilt'], ts['gcr'], 1., 1.) + with np.errstate(invalid='ignore'): + vf = utils.vf_row_sky_2d_integ(ts['surface_tilt'], ts['gcr'], 1., 1.) expected = utils.vf_row_sky_2d(ts['surface_tilt'], ts['gcr'], 1.) assert np.isclose(vf, expected) # with array input fx0 = np.array([0., 0.5]) fx1 = np.array([0., 0.8]) - vf = utils.vf_row_sky_2d_integ(ts['surface_tilt'], ts['gcr'], fx0, fx1) + with np.errstate(invalid='ignore'): + vf = utils.vf_row_sky_2d_integ(ts['surface_tilt'], ts['gcr'], fx0, fx1) phi = masking_angle(ts['surface_tilt'], ts['gcr'], fx0[0]) y0 = 0.5 * (1 + cosd(ts['surface_tilt'] + phi)) x = np.arange(fx0[1], fx1[1], 1e-4) @@ -161,13 +163,17 @@ def test_vf_row_ground_2d(test_system_fixed_tilt): def test_vf_ground_2d_integ(test_system_fixed_tilt): ts, _, _ = test_system_fixed_tilt # with float input, check end position - vf = utils.vf_row_ground_2d_integ(ts['surface_tilt'], ts['gcr'], 0., 0.) + with np.errstate(invalid='ignore'): + vf = utils.vf_row_ground_2d_integ(ts['surface_tilt'], ts['gcr'], + 0., 0.) expected = utils.vf_row_ground_2d(ts['surface_tilt'], ts['gcr'], 0.) assert np.isclose(vf, expected) # with array input fx0 = np.array([0., 0.5]) fx1 = np.array([0., 0.8]) - vf = utils.vf_row_ground_2d_integ(ts['surface_tilt'], ts['gcr'], fx0, fx1) + with np.errstate(invalid='ignore'): + vf = utils.vf_row_ground_2d_integ(ts['surface_tilt'], ts['gcr'], + fx0, fx1) phi = ground_angle(ts['surface_tilt'], ts['gcr'], fx0[0]) y0 = 0.5 * (1 - cosd(phi - ts['surface_tilt'])) x = np.arange(fx0[1], fx1[1], 1e-4) diff --git a/pvlib/tests/iotools/test_pvgis.py b/pvlib/tests/iotools/test_pvgis.py index 9f81fa02a6..45c4cde46b 100644 --- a/pvlib/tests/iotools/test_pvgis.py +++ b/pvlib/tests/iotools/test_pvgis.py @@ -201,8 +201,9 @@ def test_read_pvgis_hourly_bad_extension(): # Test if ValueError is raised if an unkonwn pvgis_format is specified with pytest.raises(ValueError, match="pvgis format 'txt' was unknown"): read_pvgis_hourly(testfile_pv_json, pvgis_format='txt') - # Test if TypeError is raised if input is a buffer and pvgis_format=None - with pytest.raises(TypeError, match="expected str, bytes or os.PathLike"): + # Test if TypeError is raised if input is a buffer and pvgis_format=None. + # The error text changed in python 3.12. This regex matches both versions: + with pytest.raises(TypeError, match="str.*os.PathLike"): read_pvgis_hourly(io.StringIO())