Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
echedey-ls committed Feb 10, 2024
1 parent 049a02d commit 0128477
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,11 +1513,14 @@ def poa_error(ghi):
full_output=True,
disp=False,
)
except ValueError:
# this occurs when poa_error has the same sign at both end points
ghi = np.nan
conv = False
niter = -1
except ValueError as e:
# this may occur because poa_error has the same sign at both end points
if "f(a) and f(b) must have different signs" in e.args:
ghi = np.nan
conv = False
niter = -1
else:
raise e
else:
ghi = result[0]
conv = result[1].converged
Expand Down
11 changes: 11 additions & 0 deletions pvlib/tests/test_irradiance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
from collections import OrderedDict
import warnings
import re

import numpy as np
from numpy import array, nan
Expand Down Expand Up @@ -825,6 +826,16 @@ def test_ghi_from_poa_driesse():
expected = [0, -1, 0]
assert_allclose(expected, niter)

# test xtol propagation by producing an exception
poa_global = pd.Series([20, 300, 1000], index=times)
xtol = -3.14159 # negative value raises exception in scipy.optimize.bisect
with pytest.raises(
ValueError,
match=re.escape("xtol too small (%g <= 0)" % xtol)):

Check failure on line 834 in pvlib/tests/test_irradiance.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E125 continuation line with same indent as next logical line
output = irradiance.ghi_from_poa_driesse_2023(
surface_tilt, surface_azimuth, zenith, azimuth,
poa_global, dni_extra=1366.1, xtol=xtol)


def test_gti_dirint():
times = pd.DatetimeIndex(
Expand Down

0 comments on commit 0128477

Please sign in to comment.