From e80355eba43d09dcb3cc3562af31b4c14ce0c5b3 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 23 Sep 2024 17:18:13 -0400 Subject: [PATCH] Remove warning message for `num_threads` in `pvlib.spa` (#2170) * fix spa numthreads warning interpolation * add test * get rid of the warning altogether * whatsnew --- docs/sphinx/source/whatsnew/v0.11.1.rst | 2 ++ pvlib/spa.py | 2 -- pvlib/tests/test_irradiance.py | 2 +- pvlib/tests/test_solarposition.py | 6 +++--- pvlib/tests/test_spa.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.11.1.rst b/docs/sphinx/source/whatsnew/v0.11.1.rst index 069fff6527..e1f487abfe 100644 --- a/docs/sphinx/source/whatsnew/v0.11.1.rst +++ b/docs/sphinx/source/whatsnew/v0.11.1.rst @@ -30,6 +30,8 @@ Enhancements * Added function for calculating wind speed at different heights, :py:func:`pvlib.atmosphere.windspeed_powerlaw`. (:issue:`2118`, :pull:`2124`) +* The multithreaded SPA functions no longer emit a warning when calculating + solar positions for short time series. (:pull:`2170`) * Implemented closed-form solution for alpha in :py:func:`pvlib.clearsky.detect_clearsky`, obviating the call to scipy.optimize that was prone to runtime errors and minimizing computation. (:issue:`2171`, :issue:`2216`, :pull:`2217`). diff --git a/pvlib/spa.py b/pvlib/spa.py index 4d2602bc3d..132cbe6b39 100644 --- a/pvlib/spa.py +++ b/pvlib/spa.py @@ -937,8 +937,6 @@ def solar_position_numba(unixtime, lat, lon, elev, pressure, temp, delta_t, unixtime = unixtime.astype(np.float64) if ulength < numthreads: - warnings.warn('The number of threads is more than the length of ' - 'the time array. Only using %s threads.'.format(ulength)) numthreads = ulength if numthreads <= 1: diff --git a/pvlib/tests/test_irradiance.py b/pvlib/tests/test_irradiance.py index 0eb951f9a1..82463e0b0f 100644 --- a/pvlib/tests/test_irradiance.py +++ b/pvlib/tests/test_irradiance.py @@ -106,7 +106,7 @@ def test_get_extra_radiation_epoch_year(): @requires_numba def test_get_extra_radiation_nrel_numba(times): with warnings.catch_warnings(): - # don't warn on method reload or num threads + # don't warn on method reload warnings.simplefilter("ignore") result = irradiance.get_extra_radiation( times, method='nrel', how='numba', numthreads=4) diff --git a/pvlib/tests/test_solarposition.py b/pvlib/tests/test_solarposition.py index 472383acce..a44b0dc0e6 100644 --- a/pvlib/tests/test_solarposition.py +++ b/pvlib/tests/test_solarposition.py @@ -490,7 +490,7 @@ def test_get_solarposition_deltat(delta_t, method, expected_solpos_multi, times = pd.date_range(datetime.datetime(2003, 10, 17, 13, 30, 30), periods=2, freq='D', tz=golden.tz) with warnings.catch_warnings(): - # don't warn on method reload or num threads + # don't warn on method reload warnings.simplefilter("ignore") ephem_data = solarposition.get_solarposition(times, golden.latitude, golden.longitude, @@ -838,7 +838,7 @@ def test_spa_python_numba_physical(expected_solpos, golden_mst): times = pd.date_range(datetime.datetime(2003, 10, 17, 12, 30, 30), periods=1, freq='D', tz=golden_mst.tz) with warnings.catch_warnings(): - # don't warn on method reload or num threads + # don't warn on method reload # ensure that numpy is the most recently used method so that # we can use the warns filter below warnings.simplefilter("ignore") @@ -865,7 +865,7 @@ def test_spa_python_numba_physical_dst(expected_solpos, golden): periods=1, freq='D', tz=golden.tz) with warnings.catch_warnings(): - # don't warn on method reload or num threads + # don't warn on method reload warnings.simplefilter("ignore") ephem_data = solarposition.spa_python(times, golden.latitude, golden.longitude, pressure=82000, diff --git a/pvlib/tests/test_spa.py b/pvlib/tests/test_spa.py index c7ebc5f9ae..f4b6dec03d 100644 --- a/pvlib/tests/test_spa.py +++ b/pvlib/tests/test_spa.py @@ -234,7 +234,7 @@ def test_topocentric_azimuth_angle(self): def test_solar_position(self): with warnings.catch_warnings(): - # don't warn on method reload or num threads + # don't warn on method reload warnings.simplefilter("ignore") spa_out_0 = self.spa.solar_position( unixtimes, lat, lon, elev, pressure, temp, delta_t,