Skip to content

Commit edea606

Browse files
authored
python >= 3.6, add scipy 1.2.0 to min requirements (#1035)
* add scipy==1.2.0 to min requirements * missed a needs numpy 10 * revert an import change in test_location * whats new * add missing requires_tables * import cleanup. fix stray requires_scipy * and fix new requires_scipy marks * remove unneeded pytest.param * fix depedency specs * lint * sdm.py import clean up * move 3.5 packages to pip. spec versions in all yml files * require python 3.6 or greater * remove 3.5 ci, rename 35 min file * update ci for 36 * remove from readme * installation instructions * fix python 3.5 references in contributing
1 parent 0271a3e commit edea606

32 files changed

+72
-354
lines changed

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ Installation
105105
pvlib-python releases may be installed using the ``pip`` and ``conda`` tools.
106106
Please see the [Installation page](http://pvlib-python.readthedocs.io/en/stable/installation.html) of the documentation for complete instructions.
107107

108-
pvlib-python is compatible with Python 3.5 and above.
109-
110-
**Python 2.7 support ended on June 1, 2019, with pvlib-python 0.6.3.**
111-
112108

113109
Contributing
114110
============

ci/azure/conda_linux.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ jobs:
88
vmImage: ${{ parameters.vmImage }}
99
strategy:
1010
matrix:
11-
Python35:
12-
python.version: '35'
13-
Python35-min:
14-
python.version: '35'
11+
Python36-min:
12+
python.version: '36'
1513
suffix: '-min'
1614
Python36:
1715
python.version: '36'

ci/azure/conda_windows.yml

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ jobs:
88
vmImage: ${{ parameters.vmImage }}
99
strategy:
1010
matrix:
11-
Python35-windows:
12-
python.version: '35'
1311
Python36-windows:
1412
python.version: '36'
1513
Python37-windows:

ci/azure/posix.yml

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ jobs:
88
vmImage: ${{ parameters.vmImage }}
99
strategy:
1010
matrix:
11-
Python35:
12-
python.version: '3.5'
1311
Python36:
1412
python.version: '3.6'
1513
Python37:

ci/requirements-py35.yml

-31
This file was deleted.

ci/requirements-py35-min.yml renamed to ci/requirements-py36-min.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ dependencies:
99
- pytest-cov
1010
- pytest-mock
1111
- pytest-timeout
12-
- python=3.5
12+
- python=3.6
1313
- pytz
1414
- requests
1515
- pip:
1616
- numpy==1.12.0
1717
- pandas==0.22.0
18+
- scipy==1.2.0
1819
- pytest-rerunfailures # conda version is >3.6
1920
- pytest-remotedata # conda package is 0.3.0, needs > 0.3.1

ci/requirements-py36.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ dependencies:
99
- netcdf4
1010
- nose
1111
- numba
12-
- numpy
13-
- pandas
12+
- numpy >= 1.12.0
13+
- pandas >= 0.22.0
1414
- pip
1515
- pytables # tables when using pip+PyPI
1616
- pytest
@@ -22,7 +22,7 @@ dependencies:
2222
- python=3.6
2323
- pytz
2424
- requests
25-
- scipy
25+
- scipy >= 1.2.0
2626
- shapely # pvfactors dependency
2727
- siphon # conda-forge
2828
- statsmodels

ci/requirements-py37.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ dependencies:
99
- netcdf4
1010
- nose
1111
- numba
12-
- numpy
13-
- pandas
12+
- numpy >= 1.12.0
13+
- pandas >= 0.22.0
1414
- pip
1515
- pytables # tables when using pip+PyPI
1616
- pytest
@@ -22,7 +22,7 @@ dependencies:
2222
- python=3.7
2323
- pytz
2424
- requests
25-
- scipy
25+
- scipy >= 1.2.0
2626
- shapely # pvfactors dependency
2727
- siphon # conda-forge
2828
- statsmodels

ci/requirements-py38.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ dependencies:
99
- netcdf4
1010
- nose
1111
- numba
12-
- numpy
13-
- pandas
12+
- numpy >= 1.12.0
13+
- pandas >= 0.22.0
1414
- pip
1515
- pytables # tables when using pip+PyPI
1616
- pytest
@@ -22,7 +22,7 @@ dependencies:
2222
- python=3.8
2323
- pytz
2424
- requests
25-
- scipy
25+
- scipy >= 1.2.0
2626
- shapely # pvfactors dependency
2727
- siphon # conda-forge
2828
- statsmodels

docs/sphinx/source/contributing.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ pvlib python generally follows the `PEP 8 -- Style Guide for Python Code
196196
<https://www.python.org/dev/peps/pep-0008/>`_. Maximum line length for code
197197
is 79 characters.
198198

199-
Code must be compatible with Python 3.5 and above.
200-
201199
pvlib python uses a mix of full and abbreviated variable names. See
202200
:ref:`variables_style_rules`. We could be better about consistency.
203201
Prefer full names for new contributions. This is especially important
@@ -475,9 +473,10 @@ PVSystem method is called through ``ModelChain.run_model``.
475473
mc.run_model(times)
476474
477475
# assertion fails if PVSystem.sapm is not called once
478-
# if using returned m, prefer this over m.assert_called_once()
479-
# for compatibility with python < 3.6
480-
assert m.call_count == 1
476+
m.assert_called_once()
477+
478+
# use `assert m.call_count == num` if function should be called
479+
# more than once
481480
482481
# ensure that dc attribute now exists and is correct type
483482
assert isinstance(mc.dc, (pd.Series, pd.DataFrame))

docs/sphinx/source/installation.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ environment) when you start a new shell or terminal.
224224
Compatibility
225225
-------------
226226

227-
pvlib-python is compatible with Python 3.5 and above.
227+
pvlib-python is compatible with Python 3.
228228

229-
pvlib-python requires Pandas and Numpy. The minimum version requirements
229+
pvlib-python requires Pandas, Numpy, and SciPy. The minimum version requirements
230230
are specified in
231231
`setup.py <https://github.com/pvlib/pvlib-python/blob/master/setup.py>`_.
232232
They are typically releases from several years ago.
@@ -235,8 +235,8 @@ A handful of pvlib-python features require additional packages that must
235235
be installed separately using pip or conda. These packages/features
236236
include:
237237

238-
* scipy: single diode model, clear sky detection
239238
* pytables (tables on PyPI): Linke turbidity look up for clear sky models
239+
* statsmodels: parameter fitting
240240
* numba: fastest solar position calculations
241241
* pyephem: solar positions calculations using an astronomical library
242242
* siphon: forecasting PV power using the pvlib.forecast module

docs/sphinx/source/whatsnew/v0.8.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ Documentation
158158

159159
Requirements
160160
~~~~~~~~~~~~
161+
* Python 3.6 or greater. (:pull:`1035`)
161162
* Minimum pandas version increased to v0.22.0, released Dec 31, 2017. (:pull:`1003`)
163+
* Scipy >= v1.2.0, released Dec 17, 2018, is now a required dependency
164+
rather an optional dependency. (:issue:`972`, :pull:`1035`)
162165

163166
Contributors
164167
~~~~~~~~~~~~

pvlib/ivtools/sdm.py

+10-19
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import numpy as np
1010

11+
import scipy.constants
12+
from scipy import optimize
13+
from scipy.special import lambertw
14+
1115
from pvlib.pvsystem import singlediode, v_from_i
1216

1317
from pvlib.ivtools.utility import constants, rectify_iv_curve, _numdiff
@@ -197,12 +201,6 @@ def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc, cells_in_series,
197201
2006.
198202
"""
199203

200-
try:
201-
from scipy.optimize import root
202-
import scipy.constants
203-
except ImportError:
204-
raise ImportError("The fit_desoto function requires scipy.")
205-
206204
# Constants
207205
k = scipy.constants.value('Boltzmann constant in eV/K')
208206
Tref = temp_ref + 273.15 # [K]
@@ -222,8 +220,8 @@ def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc, cells_in_series,
222220
Tref, k)
223221

224222
# computing with system of equations described in [1]
225-
optimize_result = root(_system_of_equations_desoto, x0=params_i,
226-
args=(specs,), **root_kwargs)
223+
optimize_result = optimize.root(_system_of_equations_desoto, x0=params_i,
224+
args=(specs,), **root_kwargs)
227225

228226
if optimize_result.success:
229227
sdm_params = optimize_result.x
@@ -657,8 +655,8 @@ def _fit_desoto_sandia_diode(ee, voc, vth, tc, specs, const):
657655
try:
658656
import statsmodels.api as sm
659657
except ImportError:
660-
raise ImportError('Parameter extraction using Sandia method requires',
661-
' statsmodels')
658+
raise ImportError(
659+
'Parameter extraction using Sandia method requires statsmodels')
662660

663661
x = specs['cells_in_series'] * vth * np.log(ee / const['E0'])
664662
y = voc - specs['beta_voc'] * (tc - const['T0'])
@@ -791,11 +789,10 @@ def _extract_sdm_params(ee, tc, iph, io, rs, rsh, n, u, specs, const,
791789
# Get single diode model parameters from five parameters iph, io, rs, rsh
792790
# and n vs. effective irradiance and temperature
793791
try:
794-
from scipy import optimize
795792
import statsmodels.api as sm
796793
except ImportError:
797-
raise ImportError('Parameter extraction using Sandia method requires',
798-
' scipy and statsmodels')
794+
raise ImportError(
795+
'Parameter extraction using Sandia method requires statsmodels')
799796

800797
tck = tc + 273.15
801798
tok = const['T0'] + 273.15 # convert to to K
@@ -1183,12 +1180,6 @@ def _calc_theta_phi_exact(vmp, imp, iph, io, rs, rsh, nnsvth):
11831180
real solar cells using Lambert W-function", Solar Energy Materials and
11841181
Solar Cells, 81 (2004) 269-277.
11851182
"""
1186-
1187-
try:
1188-
from scipy.special import lambertw
1189-
except ImportError:
1190-
raise ImportError('calc_theta_phi_exact requires scipy')
1191-
11921183
# handle singleton inputs
11931184
vmp = np.asarray(vmp)
11941185
imp = np.asarray(imp)

pvlib/scaling.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import numpy as np
77
import pandas as pd
88

9+
import scipy.optimize
10+
from scipy.spatial.distance import pdist
11+
912

1013
def wvm(clearsky_index, positions, cloud_speed, dt=None):
1114
"""
@@ -59,12 +62,6 @@ def wvm(clearsky_index, positions, cloud_speed, dt=None):
5962

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

62-
try:
63-
import scipy.optimize
64-
from scipy.spatial.distance import pdist
65-
except ImportError:
66-
raise ImportError("The WVM function requires scipy.")
67-
6865
pos = np.array(positions)
6966
dist = pdist(pos, 'euclidean')
7067
wavelet, tmscales = _compute_wavelet(clearsky_index, dt)

pvlib/singlediode.py

+5-27
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,11 @@
77
import numpy as np
88
from pvlib.tools import _golden_sect_DataFrame
99

10-
# Try to import brentq from scipy to use when specified in bishop88_i_from_v,
11-
# bishop88_v_from_i, and bishop88_mpp methods below. If not imported, raises
12-
# ImportError when 'brentq' method is specified for those methods.
13-
try:
14-
from scipy.optimize import brentq
15-
except ImportError:
16-
def brentq(*a, **kw):
17-
raise ImportError(
18-
"brentq couldn't be imported. Is SciPy installed?")
19-
20-
# FIXME: change this to newton when scipy-1.2 is released
21-
try:
22-
from scipy.optimize import _array_newton
23-
except ImportError:
24-
from pvlib.tools import _array_newton
25-
# rename newton and set keyword arguments
26-
newton = partial(_array_newton, tol=1e-6, maxiter=100, fprime2=None)
10+
from scipy.optimize import brentq, newton
11+
from scipy.special import lambertw
12+
13+
# set keyword arguments for all uses of newton in this module
14+
newton = partial(newton, tol=1e-6, maxiter=100, fprime2=None)
2715

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

511499
def _lambertw_v_from_i(resistance_shunt, resistance_series, nNsVth, current,
512500
saturation_current, photocurrent):
513-
try:
514-
from scipy.special import lambertw
515-
except ImportError:
516-
raise ImportError('This function requires scipy')
517-
518501
# Record if inputs were all scalar
519502
output_is_scalar = all(map(np.isscalar,
520503
[resistance_shunt, resistance_series, nNsVth,
@@ -592,11 +575,6 @@ def _lambertw_v_from_i(resistance_shunt, resistance_series, nNsVth, current,
592575

593576
def _lambertw_i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
594577
saturation_current, photocurrent):
595-
try:
596-
from scipy.special import lambertw
597-
except ImportError:
598-
raise ImportError('This function requires scipy')
599-
600578
# Record if inputs were all scalar
601579
output_is_scalar = all(map(np.isscalar,
602580
[resistance_shunt, resistance_series, nNsVth,

pvlib/soiling.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import datetime
77
import numpy as np
88
import pandas as pd
9+
from scipy.special import erf
10+
911
from pvlib.tools import cosd
1012

1113

@@ -62,11 +64,6 @@ def hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10,
6264
Change. J. Seinfeld and S. Pandis. Wiley and Sons 2001.
6365
6466
"""
65-
try:
66-
from scipy.special import erf
67-
except ImportError:
68-
raise ImportError("The pvlib.soiling.hsu function requires scipy.")
69-
7067
# never use mutable input arguments
7168
if depo_veloc is None:
7269
depo_veloc = {'2_5': 0.0009, '10': 0.004}

pvlib/solarposition.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import numpy as np
2222
import pandas as pd
23+
import scipy.optimize as so
2324
import warnings
2425

2526
from pvlib import atmosphere
@@ -911,12 +912,6 @@ def calc_time(lower_bound, upper_bound, latitude, longitude, attribute, value,
911912
If the given attribute is not an attribute of a
912913
PyEphem.Sun object.
913914
"""
914-
915-
try:
916-
import scipy.optimize as so
917-
except ImportError:
918-
raise ImportError('The calc_time function requires scipy')
919-
920915
obs, sun = _ephem_setup(latitude, longitude, altitude,
921916
pressure, temperature, horizon)
922917

0 commit comments

Comments
 (0)