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

Fix warning message for num_threads in pvlib.spa #2170

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ def solar_position_numba(unixtime, lat, lon, elev, pressure, temp, delta_t,

if ulength < numthreads:
warnings.warn('The number of threads is more than the length of '
'the time array. Only using %s threads.'.format(ulength))
f'the time array. Only using {ulength} threads.')
numthreads = ulength

if numthreads <= 1:
Expand Down
6 changes: 6 additions & 0 deletions pvlib/tests/test_spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,9 @@ def test_solar_position_multithreaded(self):
nresult, self.spa.solar_position(
times, lat, lon, elev, pressure, temp, delta_t,
atmos_refract, numthreads=3, sst=True)[:3], 5)

def test_solar_position_warn_too_many_threads(self):
two_timestamps = np.array([unixtimes[0], unixtimes[0]])
with self.assertWarnsRegex(UserWarning, '.*Only using 2 threads.'):
self.spa.solar_position(two_timestamps, lat, lon, elev, pressure,
temp, delta_t, atmos_refract, numthreads=3)
Loading