10000 python >= 3.6, add scipy 1.2.0 to min requirements by wholmgren · Pull Request #1035 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

python >= 3.6, add scipy 1.2.0 to min requirements #1035

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 19 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions ci/requirements-py35-min.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ dependencies:
- pip:
- numpy==1.12.0
- pandas==0.22.0
- scipy==1.2.0
- pytest-rerunfailures # conda version is >3.6
- pytest-remotedata # conda package is 0.3.0, needs > 0.3.1
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ Documentation
Requirements
~~~~~~~~~~~~
* Minimum pandas version increased to v0.22.0, released Dec 31, 2017. (:pull:`1003`)
* Scipy >= v1.2.0, released Dec 17, 2018, is now a required dependency
rather an optional dependency. (:issue:`972`, :pull:`1035`)

Contributors
~~~~~~~~~~~~
Expand Down
9 changes: 3 additions & 6 deletions pvlib/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import numpy as np
import pandas as pd

import scipy.optimize
from scipy.spatial.distance import pdist


def wvm(clearsky_index, positions, cloud_speed, dt=None):
"""
Expand Down Expand Up @@ -59,12 +62,6 @@ def wvm(clearsky_index, positions, cloud_speed, dt=None):

# Added by Joe Ranalli (@jranalli), Penn State Hazleton, 2019

try:
import scipy.optimize
from scipy.spatial.distance import pdist
except ImportError:
raise ImportError("The WVM function requires scipy.")

pos = np.array(positions)
dist = pdist(pos, 'euclidean')
wavelet, tmscales = _compute_wavelet(clearsky_index, dt)
Expand Down
32 changes: 5 additions & 27 deletions pvlib/singlediode.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,11 @@
import numpy as np
from pvlib.tools import _golden_sect_DataFrame

# Try to import brentq from scipy to use when s 8000 pecified in bishop88_i_from_v,
# bishop88_v_from_i, and bishop88_mpp methods below. If not imported, raises
# ImportError when 'brentq' method is specified for those methods.
try:
from scipy.optimize import brentq
except ImportError:
def brentq(*a, **kw):
raise ImportError(
"brentq couldn't be imported. Is SciPy installed?")

# FIXME: change this to newton when scipy-1.2 is released
try:
from scipy.optimize import _array_newton
except ImportError:
from pvlib.tools import _array_newton
# rename newton and set keyword arguments
newton = partial(_array_newton, tol=1e-6, maxiter=100, fprime2=None)
from scipy.optimize import brentq, newton
from scipy.special import lambertw

# set keyword arguments for all uses of newton in this module
newton = partial(newton, tol=1e-6, maxiter=100, fprime2=None)

# intrinsic voltage per cell junction for a:Si, CdTe, Mertens et al.
VOLTAGE_BUILTIN = 0.9 # [V]
Expand Down Expand Up @@ -510,11 +498,6 @@ def _prepare_newton_inputs(i_or_v_tup, args, v0):

def _lambertw_v_from_i(resistance_shunt, resistance_series, nNsVth, current,
saturation_current, photocurrent):
try:
from scipy.special import lambertw
except ImportError:
raise ImportError('This function requires scipy')

# Record if inputs were all scalar
output_is_scalar = all(map(np.isscalar,
[resistance_shunt, resistance_series, nNsVth,
Expand Down Expand Up @@ -592,11 +575,6 @@ def _lambertw_v_from_i(resistance_shunt, resistance_series, nNsVth, current,

def _lambertw_i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
saturation_current, photocurrent):
try:
from scipy.special import lambertw
except ImportError:
raise ImportError('This function requires scipy')

# Record if inputs were all scalar
output_is_scalar = all(map(np.isscalar,
[resistance_shunt, resistance_series, nNsVth,
Expand Down
7 changes: 2 additions & 5 deletions pvlib/soiling.py
B94A
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import datetime
import numpy as np
import pandas as pd
from scipy.special import erf

from pvlib.tools import cosd


Expand Down Expand Up @@ -62,11 +64,6 @@ def hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10,
Change. J. Seinfeld and S. Pandis. Wiley and Sons 2001.

"""
try:
from scipy.special import erf
except ImportError:
raise ImportError("The pvlib.soiling.hsu function requires scipy.")

# never use mutable input arguments
if depo_veloc is None:
depo_veloc = {'2_5': 0.0009, '10': 0.004}
Expand Down
7 changes: 1 addition & 6 deletions pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import numpy as np
import pandas as pd
import scipy.optimize as so
import warnings

from pvlib import atmosphere
Expand Down Expand Up @@ -911,12 +912,6 @@ def calc_time(lower_bound, upper_bound, latitude, longitude, attribute, value,
If the given attribute is not an attribute of a
PyEphem.Sun object.
"""

try:
import scipy.optimize as so
except ImportError:
raise ImportError('The calc_time function requires scipy')

obs, sun = _ephem_setup(latitude, longitude, altitude,
pressure, temperature, horizon)

Expand Down
17 changes: 0 additions & 17 deletions pvlib/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import platform
import warnings

import numpy as np
import pandas as pd
from pkg_resources import parse_version
import pytest
Expand Down Expand Up @@ -81,14 +80,6 @@ def assert_frame_equal(left, right, **kwargs):
skip_windows = pytest.mark.skipif(platform_is_windows,
reason='does not run on windows')

try:
import scipy
has_scipy = True
except ImportError:
has_scipy = False

requires_scipy = pytest.mark.skipif(not has_scipy, reason='requires scipy')


try:
import statsmodels # noqa: F401
Expand Down Expand Up @@ -118,14 +109,6 @@ def assert_frame_equal(left, right, **kwargs):
requires_ephem = pytest.mark.skipif(not has_ephem, reason='requires ephem')


def numpy_1_10():
return parse_version(np.__version__) >= parse_version('1.10.0')


needs_numpy_1_10 = pytest.mark.skipif(
not numpy_1_10(), reason='requires numpy 1.10 or greater')


def has_spa_c():
try:
from pvlib.spa_c_files.spa_py import spa_calc
Expand Down
3 changes: 0 additions & 3 deletions pvlib/tests/ivtools/test_sde.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import pytest
from pvlib import pvsystem
from pvlib.ivtools import sde
from pvlib.tests.conftest import requires_scipy


@pytest.fixture
def get_test_iv_params():
return {'IL': 8.0, 'I0': 5e-10, 'Rs': 0.2, 'Rsh': 1000, 'nNsVth': 1.61864}


@requires_scipy
def test_fit_sandia_simple(get_test_iv_params, get_bad_iv_curves):
test_params = get_test_iv_params
testcurve = pvsystem.singlediode(photocurrent=test_params['IL'],
Expand Down Expand Up @@ -41,7 +39,6 @@ def test_fit_sandia_simple(get_test_iv_params, get_bad_iv_curves):
assert np.allclose(result, expected, rtol=5e-5)


@requires_scipy
def test_fit_sandia_simple_bad_iv(get_bad_iv_curves):
# bad IV curves for coverage of if/then in sde._sandia_simple_params
v1, i1, v2, i2 = get_bad_iv_curves
Expand Down
16 changes: 1 addition & 15 deletions pvlib/tests/ivtools/test_sdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from pvlib.ivtools import sdm
from pvlib import pvsystem

from pvlib.tests.conftest import requires_scipy, requires_pysam
from pvlib.tests.conftest import requires_statsmodels
from pvlib.tests.conftest import requires_pysam, requires_statsmodels

from conftest import DATA_DIR

Expand Down Expand Up @@ -61,7 +60,6 @@ def test_fit_cec_sam_estimation_failure(cec_params_cansol_cs5p_220p):
gamma_pmp=0.0055, cells_in_series=1, temp_ref=25)


@requires_scipy
def test_fit_desoto():
result, _ = sdm.fit_desoto(v_mp=31.0, i_mp=8.71, v_oc=38.3, i_sc=9.43,
alpha_sc=0.005658, beta_voc=-0.13788,
Expand All @@ -80,7 +78,6 @@ def test_fit_desoto():
rtol=1e-4)


@requires_scipy
def test_fit_desoto_failure():
with pytest.raises(RuntimeError) as exc:
sdm.fit_desoto(v_mp=31.0, i_mp=8.71, v_oc=38.3, i_sc=9.43,
Expand All @@ -89,7 +86,6 @@ def test_fit_desoto_failure():
assert ('Parameter estimation failed') in str(exc.value)


@requires_scipy
@requires_statsmodels
def test_fit_desoto_sandia(cec_params_cansol_cs5p_220p):
# this test computes a set of IV curves for the input fixture, fits
Expand Down Expand Up @@ -224,7 +220,6 @@ def _read_pvsyst_expected(datafile):
return pvsyst_specs, pvsyst


@requires_scipy
@requires_statsmodels
def test_fit_pvsyst_sandia(npts=3000):

Expand Down Expand Up @@ -295,7 +290,6 @@ def test_fit_pvsyst_sandia(npts=3000):
equal_nan=True, rtol=0.63)


@requires_scipy
@pytest.mark.parametrize('vmp, imp, iph, io, rs, rsh, nnsvth, expected', [
(2., 2., 2., 2., 2., 2., 2., np.nan),
(2., 2., 0., 2., 2., 2., 2., np.nan),
Expand All @@ -309,14 +303,12 @@ def test__update_rsh_fixed_pt_nans(vmp, imp, iph, io, rs, rsh, nnsvth,
assert np.all(np.isnan(outrsh))


@requires_scipy
def test__update_rsh_fixed_pt_vmp0():
outrsh = sdm._update_rsh_fixed_pt(vmp=0., imp=2., iph=2., io=2., rs=2.,
rsh=2., nnsvth=2.)
np.testing.assert_allclose(outrsh, np.array([502.]), atol=.0001)


@requires_scipy
def test__update_rsh_fixed_pt_vector():
outrsh = sdm._update_rsh_fixed_pt(rsh=np.array([-1., 3, .5, 2.]),
rs=np.array([1., -.5, 2., 2.]),
Expand All @@ -329,7 +321,6 @@ def test__update_rsh_fixed_pt_vector():
np.testing.assert_allclose(outrsh[3], np.array([502.]), atol=.0001)


@requires_scipy
@pytest.mark.parametrize('voc, iph, io, rs, rsh, nnsvth, expected', [
(2., 2., 2., 2., 2., 2., 0.5911),
(2., 2., 2., 0., 2., 2., 0.5911),
Expand All @@ -341,7 +332,6 @@ def test__update_io(voc, iph, io, rs, rsh, nnsvth, expected):
np.testing.assert_allclose(outio, expected, atol=.0001)


@requires_scipy
@pytest.mark.parametrize('voc, iph, io, rs, rsh, nnsvth', [
(2., 2., 2., 2., 2., 0.),
(-1., -1., -1., -1., -1., -1.)])
Expand All @@ -350,7 +340,6 @@ def test__update_io_nan(voc, iph, io, rs, rsh, nnsvth):
assert np.isnan(outio)


@requires_scipy
@pytest.mark.parametrize('vmp, imp, iph, io, rs, rsh, nnsvth, expected', [
(2., 2., 2., 2., 2., 2., 2., (1.8726, 2.)),
(2., 0., 2., 2., 2., 2., 2., (1.8726, 3.4537)),
Expand All @@ -362,7 +351,6 @@ def test__calc_theta_phi_exact(vmp, imp, iph, io, rs, rsh, nnsvth, expected):
np.testing.assert_allclose(phi, expected[1], atol=.0001)


@requires_scipy
@pytest.mark.parametrize('vmp, imp, iph, io, rs, rsh, nnsvth', [
(2., 2., 2., 0., 2., 2., 2.),
(2., 2., 2., 2., 2., 2., 0.),
Expand All @@ -373,15 +361,13 @@ def test__calc_theta_phi_exact_both_nan(vmp, imp, iph, io, rs, rsh, nnsvth):
assert np.isnan(phi)


@requires_scipy
def test__calc_theta_phi_exact_one_nan():
theta, phi = sdm._calc_theta_phi_exact(imp=2., iph=2., vmp=2., io=2.,
nnsvth=2., rs=0., rsh=2.)
assert np.isnan(theta)
np.testing.assert_allclose(phi, 2., atol=.0001)


@requires_scipy
def test__calc_theta_phi_exact_vector():
theta, phi = sdm._calc_theta_phi_exact(imp=np.array([1., -1.]),
iph=np.array([-1., 1.]),
Expand Down
9 changes: 1 addition & 8 deletions pvlib/tests/test_clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pvlib import atmosphere
from pvlib import irradiance

from conftest import requires_scipy, requires_tables, DATA_DIR
from conftest import requires_tables, DATA_DIR


def test_ineichen_series():
Expand Down Expand Up @@ -546,7 +546,6 @@ def detect_clearsky_data():
return expected, cs


@requires_scipy
def test_detect_clearsky(detect_clearsky_data):
expected, cs = detect_clearsky_data
clear_samples = clearsky.detect_clearsky(
Expand All @@ -555,7 +554,6 @@ def test_detect_clearsky(detect_clearsky_data):
check_dtype=False, check_names=False)


@requires_scipy
def test_detect_clearsky_components(detect_clearsky_data):
expected, cs = detect_clearsky_data
clear_samples, components, alpha = clearsky.detect_clearsky(
Expand All @@ -566,7 +564,6 @@ def test_detect_clearsky_components(detect_clearsky_data):
assert np.allclose(alpha, 0.9633903181941296)


@requires_scipy
def test_detect_clearsky_iterations(detect_clearsky_data):
expected, cs = detect_clearsky_data
alpha = 1.0448
Expand All @@ -581,7 +578,6 @@ def test_detect_clearsky_iterations(detect_clearsky_data):
check_dtype=False, check_names=False)


@requires_scipy
def test_detect_clearsky_kwargs(detect_clearsky_data):
expected, cs = detect_clearsky_data
clear_samples = clearsky.detect_clearsky(
Expand All @@ -591,7 +587,6 @@ def test_detect_clearsky_kwargs(detect_clearsky_data):
assert clear_samples.all()


@requires_scipy
def test_detect_clearsky_window(detect_clearsky_data):
expected, cs = detect_clearsky_data
clear_samples = clearsky.detect_clearsky(
Expand All @@ -602,7 +597,6 @@ def test_detect_clearsky_window(detect_clearsky_data):
check_dtype=False, check_names=False)


@requires_scipy
def test_detect_clearsky_arrays(detect_clearsky_data):
expected, cs = detect_clearsky_data
clear_samples = clearsky.detect_clearsky(
Expand All @@ -611,7 +605,6 @@ def test_detect_clearsky_arrays(detect_clearsky_data):
assert (clear_samples == expected['Clear or not'].values).all()


@requires_scipy
def test_detect_clearsky_irregular_times(detect_clearsky_data):
expected, cs = detect_clearsky_data
times = cs.index.values.copy()
Expand Down
4295
Loading
0