Skip to content

Commit 65782fd

Browse files
authored
Make tables a required dependency (#1287)
* make tables a required dep, remove requires_tables test decorator * whatsnew * add tables to 3.6-min yml * use pip for tables on 3.6 and 3.7 for windows DLL load issue * use pip tables on 3.6-min for numpy compat issue * only install tables by default if not (OSX & 3.9) * remove tables from 3.6-min * forgot the OS X part * put back requires_tables decorator * fix silly bug * reset back to 636da68 * inelegantly disable mac os/py 3.9 job * add pytables to 3.6-min * fix posix.yml condition * try different string interpolation * I don't understand azure variables so skip mac/3.9 this way instead * pin to blosc to older version to get tables working on win 3.6 and 3.7 * pin an older numexpr compatible with our min numpy for 3.6-min * promote tables to a normal import in clearsky.py
1 parent 6c857ae commit 65782fd

12 files changed

+53
-35
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
vmImage: ubuntu-16.04
1313

1414

15-
- template: ci/azure/posix.yml
15+
- template: ci/azure/posix_no_39.yml
1616
parameters:
1717
name: Test_bare_macOS
1818
vmImage: macOS-10.14

ci/azure/posix_no_39.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
parameters:
2+
name: ''
3+
vmImage: ''
4+
5+
jobs:
6+
- job: ${{ parameters.name }}
7+
pool:
8+
vmImage: ${{ parameters.vmImage }}
9+
strategy:
10+
matrix:
11+
Python36:
12+
python.version: '3.6'
13+
Python37:
14+
python.version: '3.7'
15+
Python38:
16+
python.version: '3.8'
17+
18+
steps:
19+
- task: UsePythonVersion@0
20+
inputs:
21+
versionSpec: '$(python.version)'
22+
23+
- script: |
24+
pip install pytest pytest-cov pytest-mock requests-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pytest-remotedata
25+
pip install -e .
26+
pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
27+
displayName: 'Test with pytest'
28+
29+
- task: PublishTestResults@2
30+
condition: succeededOrFailed()
31+
inputs:
32+
testResultsFiles: '**/test-*.xml'
33+
testRunTitle: 'Publish test results for Python $(python.version)'
34+
35+
- task: PublishCodeCoverageResults@1
36+
inputs:
37+
codeCoverageTool: Cobertura
38+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
39+
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'

ci/requirements-py36-min.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dependencies:
55
- coveralls
66
- nose
77
- pip
8+
- pytables # tables when using pip+PyPI
89
- pytest
910
- pytest-cov
1011
- pytest-mock
@@ -20,3 +21,4 @@ dependencies:
2021
- pytest-rerunfailures # conda version is >3.6
2122
- pytest-remotedata # conda package is 0.3.0, needs > 0.3.1
2223
- requests-mock
24+
- numexpr==2.6.2 # needed for tables, but newest version is not compatible with numpy 1.12

ci/requirements-py36.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ channels:
33
- defaults
44
- conda-forge
55
dependencies:
6+
- blosc=1.14.3 # newest version breaks tables (pytables) on windows
67
- coveralls
78
- cython
89
- ephem

ci/requirements-py37.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ channels:
33
- defaults
44
- conda-forge
55
dependencies:
6+
- blosc=1.14.3 # newest version breaks tables (pytables) on windows
67
- coveralls
78
- cython
89
- ephem

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ Documentation
230230

231231
Requirements
232232
~~~~~~~~~~~~
233-
* ``dataclasses`` is required for python 3.6
233+
* ``dataclasses`` is required for python 3.6 (:pull:`1076`)
234+
* ``tables`` is now required instead of optional (:issue:`1286`, :pull:`1287`)
234235

235236
Contributors
236237
~~~~~~~~~~~~

pvlib/clearsky.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pandas as pd
1212
from scipy.optimize import minimize_scalar
1313
from scipy.linalg import hankel
14+
import tables
1415

1516
from pvlib import atmosphere, tools
1617

@@ -186,13 +187,6 @@ def lookup_linke_turbidity(time, latitude, longitude, filepath=None,
186187
# 1st row: 89.9583 S, 2nd row: 89.875 S
187188
# 1st column: 179.9583 W, 2nd column: 179.875 W
188189

189-
try:
190-
import tables
191-
except ImportError:
192-
raise ImportError('The Linke turbidity lookup table requires tables. '
193-
'You can still use clearsky.ineichen if you '
194-
'supply your own turbidities.')
195-
196190
if filepath is None:
197191
pvlib_path = os.path.dirname(os.path.abspath(__file__))
198192
filepath = os.path.join(pvlib_path, 'data', 'LinkeTurbidities.h5')

pvlib/tests/conftest.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ def assert_frame_equal(left, right, **kwargs):
105105
not has_statsmodels, reason='requires statsmodels')
106106

107107

108-
try:
109-
import tables
110-
has_tables = True
111-
except ImportError:
112-
has_tables = False
113-
114-
requires_tables = pytest.mark.skipif(not has_tables, reason='requires tables')
115-
116-
117108
try:
118109
import ephem
119110
has_ephem = True

pvlib/tests/test_clearsky.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pvlib import atmosphere
1717
from pvlib import irradiance
1818

19-
from .conftest import requires_tables, DATA_DIR
19+
from .conftest import DATA_DIR
2020

2121

2222
def test_ineichen_series():
@@ -189,7 +189,6 @@ def test_ineichen_altitude():
189189
assert_frame_equal(expected, out)
190190

191191

192-
@requires_tables
193192
def test_lookup_linke_turbidity():
194193
times = pd.date_range(start='2014-06-24', end='2014-06-25',
195194
freq='12h', tz='America/Phoenix')
@@ -202,7 +201,6 @@ def test_lookup_linke_turbidity():
202201
assert_series_equal(expected, out)
203202

204203

205-
@requires_tables
206204
def test_lookup_linke_turbidity_leapyear():
207205
times = pd.date_range(start='2016-06-24', end='2016-06-25',
208206
freq='12h', tz='America/Phoenix')
@@ -215,7 +213,6 @@ def test_lookup_linke_turbidity_leapyear():
215213
assert_series_equal(expected, out)
216214

217215

218-
@requires_tables
219216
def test_lookup_linke_turbidity_nointerp():
220217
times = pd.date_range(start='2014-06-24', end='2014-06-25',
221218
freq='12h', tz='America/Phoenix')
@@ -226,7 +223,6 @@ def test_lookup_linke_turbidity_nointerp():
226223
assert_series_equal(expected, out)
227224

228225

229-
@requires_tables
230226
def test_lookup_linke_turbidity_months():
231227
times = pd.date_range(start='2014-04-01', end='2014-07-01',
232228
freq='1M', tz='America/Phoenix')
@@ -237,7 +233,6 @@ def test_lookup_linke_turbidity_months():
237233
assert_series_equal(expected, out)
238234

239235

240-
@requires_tables
241236
def test_lookup_linke_turbidity_months_leapyear():
242237
times = pd.date_range(start='2016-04-01', end='2016-07-01',
243238
freq='1M', tz='America/Phoenix')
@@ -248,7 +243,6 @@ def test_lookup_linke_turbidity_months_leapyear():
248243
assert_series_equal(expected, out)
249244

250245

251-
@requires_tables
252246
def test_lookup_linke_turbidity_nointerp_months():
253247
times = pd.date_range(start='2014-04-10', end='2014-07-10',
254248
freq='1M', tz='America/Phoenix')
@@ -480,7 +474,6 @@ def test_simplified_solis_nans_series():
480474
assert_frame_equal(expected, out)
481475

482476

483-
@requires_tables
484477
def test_linke_turbidity_corners():
485478
"""Test Linke turbidity corners out of bounds."""
486479
months = pd.DatetimeIndex('%d/1/2016' % (m + 1) for m in range(12))

pvlib/tests/test_location.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from pvlib.location import Location
1616
from pvlib.solarposition import declination_spencer71
1717
from pvlib.solarposition import equation_of_time_spencer71
18-
from .conftest import requires_ephem, requires_tables
18+
from .conftest import requires_ephem
1919

2020

2121
def test_location_required():
@@ -77,7 +77,6 @@ def times():
7777
freq='3H')
7878

7979

80-
@requires_tables
8180
def test_get_clearsky(mocker, times):
8281
tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson')
8382
m = mocker.spy(pvlib.clearsky, 'ineichen')

pvlib/tests/test_modelchain.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .conftest import assert_series_equal, assert_frame_equal
1414
import pytest
1515

16-
from .conftest import fail_on_pvlib_version, requires_tables
16+
from .conftest import fail_on_pvlib_version
1717

1818

1919
@pytest.fixture(scope='function')
@@ -1788,7 +1788,6 @@ def test_ModelChain_attributes_deprecated_10(sapm_dc_snl_ac_system, location):
17881788
mc.aoi = 5
17891789

17901790

1791-
@requires_tables
17921791
def test_basic_chain_alt_az(sam_data, cec_inverter_parameters,
17931792
sapm_temperature_cs5p_220m):
17941793
times = pd.date_range(start='20160101 1200-0700',
@@ -1810,7 +1809,6 @@ def test_basic_chain_alt_az(sam_data, cec_inverter_parameters,
18101809
assert_series_equal(ac, expected)
18111810

18121811

1813-
@requires_tables
18141812
def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters,
18151813
sapm_temperature_cs5p_220m):
18161814
times = pd.date_range(start='20160101 1200-0700',
@@ -1861,7 +1859,6 @@ def test_complete_irradiance_clean_run(sapm_dc_snl_ac_system, location):
18611859
pd.Series([9, 5], index=times, name='ghi'))
18621860

18631861

1864-
@requires_tables
18651862
def test_complete_irradiance(sapm_dc_snl_ac_system, location):
18661863
"""Check calculations"""
18671864
mc = ModelChain(sapm_dc_snl_ac_system, location)
@@ -1890,7 +1887,6 @@ def test_complete_irradiance(sapm_dc_snl_ac_system, location):
18901887

18911888
@pytest.mark.filterwarnings("ignore:This function is not safe at the moment")
18921889
@pytest.mark.parametrize("input_type", [tuple, list])
1893-
@requires_tables
18941890
def test_complete_irradiance_arrays(
18951891
sapm_dc_snl_ac_system_same_arrays, location, input_type):
18961892
"""ModelChain.complete_irradiance can accept a tuple of weather

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
'pandas >= 0.22.0',
4343
'pytz',
4444
'requests',
45-
'scipy >= 1.2.0']
45+
'scipy >= 1.2.0',
46+
'tables']
4647

4748
# include dataclasses as a dependency only on python 3.6
4849
if sys.version_info.major == 3 and sys.version_info.minor == 6:
@@ -53,7 +54,7 @@
5354
'pytest-remotedata']
5455
EXTRAS_REQUIRE = {
5556
'optional': ['cython', 'ephem', 'netcdf4', 'nrel-pysam', 'numba',
56-
'pvfactors', 'siphon', 'statsmodels', 'tables',
57+
'pvfactors', 'siphon', 'statsmodels',
5758
'cftime >= 1.1.1'],
5859
'doc': ['ipython', 'matplotlib', 'sphinx == 3.1.2',
5960
'sphinx_rtd_theme==0.5.0', 'sphinx-gallery', 'docutils == 0.15.2',

0 commit comments

Comments
 (0)