Skip to content

numpy 1.16 compatibility #644

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

Merged
merged 2 commits into from
Jan 21, 2019
Merged
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: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.6.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Bug fixes
* Fix error in ``pvlib.spa`` when using Python 3.7 on some platforms.
* Fix error in :func:`pvlib.irradiance._delta_kt_prime_dirint` (:issue:`637`). The error affects
the first and last values of DNI calculated by the function :func:`pvlib.irradiance.dirint`
* Fix errors on Python 2.7 and Numpy 1.6. (:issue:`642`)
* Replace deprecated `np.asscalar` with `array.item()`. (:issue:`642`)


Testing
Expand Down
1 change: 1 addition & 0 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
# sense for small zenith angles, but...) these values will
# eventually be used as indicies for coeffecient look ups
ebin = np.digitize(eps, (0., 1.065, 1.23, 1.5, 1.95, 2.8, 4.5, 6.2))
ebin = np.array(ebin) # GH 642
ebin[np.isnan(eps)] = 0

# correct for 0 indexing in coeffecient lookup
Expand Down
4 changes: 2 additions & 2 deletions pvlib/singlediode.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _lambertw_v_from_i(resistance_shunt, resistance_series, nNsVth, current,
I[idx_p] * Rs[idx_p] - a[idx_p] * lambertwterm

if output_is_scalar:
return np.asscalar(V)
return V.item()
else:
return V

Expand Down Expand Up @@ -528,7 +528,7 @@ def _lambertw_i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
a[idx_p] / Rs[idx_p]) * lambertwterm

if output_is_scalar:
return np.asscalar(I)
return I.item()
else:
return I

Expand Down
2 changes: 1 addition & 1 deletion pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ def calculate_deltat(year, month):

-20+32*((y-1820)/100)**2, deltat)

deltat = np.asscalar(deltat) if np.isscalar(year) & np.isscalar(month)\
deltat = deltat.item() if np.isscalar(year) & np.isscalar(month)\
else deltat

return deltat
2 changes: 2 additions & 0 deletions pvlib/test/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ def test_perez_scalar():
out = irradiance.perez(40, 180, 118.45831879, 939.95469881,
1321.1655834833093, 10.56413562, 144.76567754,
1.01688136)
# this will fail. out is ndarry with ndim == 0. fix in future version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to open an issue to track this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added #646

# assert np.isscalar(out)
assert_allclose(out, 109.084332)


Expand Down
1 change: 0 additions & 1 deletion pvlib/test/test_solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ def test_get_solarposition_altitude(altitude, expected, golden):
pytest.param(
None, 'nrel_numba',
marks=[pytest.mark.xfail(
raises=ValueError,
reason='spa.calculate_deltat not implemented for numba yet')]),
(67.0, 'nrel_numba')
])
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _scalar_out(input):
else: #
# works if it's a 1 length array and
# will throw a ValueError otherwise
output = np.asscalar(input)
output = input.item()

return output

Expand Down