Skip to content

Commit

Permalink
Remove warning message for num_threads in pvlib.spa (#2170)
Browse files Browse the repository at this point in the history
* fix spa numthreads warning interpolation

* add test

* get rid of the warning altogether

* whatsnew
  • Loading branch information
kandersolar authored Sep 23, 2024
1 parent d8ea82b commit e80355e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
2 changes: 0 additions & 2 deletions pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pvlib/tests/test_solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/test_spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e80355e

Please sign in to comment.