Skip to content

Commit eba1777

Browse files
cwhanseechedey-ls
andauthored
Apply suggestions from code review
Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com>
1 parent 9a0cf85 commit eba1777

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

pvlib/ivtools/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ def _lambertw_pvlib(x):
593593
# for small x, solve 0 = g(w) = w * exp(w) - x using Halley's method
594594
if np.any(small):
595595
z = localx[small]
596-
temp = np.log(localx[small] + 1)
597-
g = temp - np.log(temp + 1)
596+
temp = np.log1p(localx[small])
597+
g = temp - np.log1p(temp)
598598
for _ in range(0, 3):
599599
expg = np.exp(g)
600600
g_expg_z = g*expg - z

tests/ivtools/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ def test_lambertw_pvlib():
185185
result = _lambertw_pvlib(test_x)
186186
assert np.allclose(result, expected, rtol=1e-14)
187187
# with float input
188-
for x, k in zip([1.e-10, 1.e+10], [1, 5]):
188+
for x, k in zip(test_x[[1, 5]], expected[[1, 5]]):
189189
result = _lambertw_pvlib(x)
190190
assert np.isclose(result, expected[k])
191191
# with 1d array
192-
for x, k in zip([1.e-10, 1.e+10], [1, 5]):
192+
for x, k in zip(test_x[[1, 5]], expected[[1, 5]]):
193193
result = _lambertw_pvlib(np.array([x]))
194194
assert np.isclose(result, expected[k])

0 commit comments

Comments
 (0)