diff --git a/pvlib/tools.py b/pvlib/tools.py index ce92fbd681..a81306b60c 100644 --- a/pvlib/tools.py +++ b/pvlib/tools.py @@ -435,8 +435,10 @@ def _get_sample_intervals(times, win_length): ) # determine if we can proceed - if (_pandas_infer_freq_BaseOffset_transition_handler(times) - and len(np.unique(deltas)) == 1): + if ( # infer wrapper is None if no freq is determined + _pandas_infer_freq_BaseOffset_transition_handler(times) + and len(np.unique(deltas)) == 1 + ): sample_interval = times[1] - times[0] sample_interval = sample_interval.seconds / 60 # in minutes samples_per_window = int(win_length / sample_interval) @@ -476,7 +478,7 @@ def _pandas_infer_freq_BaseOffset_transition_handler(times): [^1]: pandas PR GH#64679: https://github.com/pandas-dev/pandas/pull/64679 [^2]: https://pandas.pydata.org/docs/reference/api/pandas.infer_freq.html [^3]: https://pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BaseOffset.html - """ + """ # noqa: E501 if Version(pd.__version__) < Version("3.1.0rc0"): return pd.infer_freq(times) with pd.option_context({'future.infer_freq_returns_offset': True}): @@ -485,6 +487,7 @@ def _pandas_infer_freq_BaseOffset_transition_handler(times): # base_offset:=None if unable to infer return getattr(base_offset, "freqstr", None) + def _degrees_to_index(degrees, coordinate): """Transform input degrees to an output index integer. Specify a degree value and either 'latitude' or 'longitude' to get diff --git a/tests/test_solarposition.py b/tests/test_solarposition.py index fc31094362..9ee1ad05ea 100644 --- a/tests/test_solarposition.py +++ b/tests/test_solarposition.py @@ -831,13 +831,16 @@ def test_sun_rise_set_transit_geometric(expected_rise_set_spa, golden_mst): test_transit = solarposition._times_to_hours_after_local_midnight(st) # convert expected SPA sunrise, sunset, transit to local datetime indices expected_sunrise = pd.DatetimeIndex( - expected_rise_set_spa["sunrise"].dt.tz_convert(None).to_numpy(), tz="UTC" + expected_rise_set_spa["sunrise"].dt.tz_convert(None).to_numpy(), + tz="UTC", ).tz_convert(golden_mst.tz) expected_sunset = pd.DatetimeIndex( - expected_rise_set_spa["sunset"].dt.tz_convert(None).to_numpy(), tz="UTC" + expected_rise_set_spa["sunset"].dt.tz_convert(None).to_numpy(), + tz="UTC", ).tz_convert(golden_mst.tz) expected_transit = pd.DatetimeIndex( - expected_rise_set_spa["transit"].dt.tz_convert(None).to_numpy(), tz="UTC" + expected_rise_set_spa["transit"].dt.tz_convert(None).to_numpy(), + tz="UTC", ).tz_convert(golden_mst.tz) # convert expected times to hours since midnight as arrays of floats expected_sunrise = solarposition._times_to_hours_after_local_midnight(