Skip to content

Make tables a required dependency #1287

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
Aug 24, 2021
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: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
vmImage: ubuntu-16.04


- template: ci/azure/posix.yml
- template: ci/azure/posix_no_39.yml
parameters:
name: Test_bare_macOS
vmImage: macOS-10.14
Expand Down
39 changes: 39 additions & 0 deletions ci/azure/posix_no_39.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
parameters:
name: ''
vmImage: ''

jobs:
- job: ${{ parameters.name }}
pool:
vmImage: ${{ parameters.vmImage }}
strategy:
matrix:
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'
Python38:
python.version: '3.8'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'

- script: |
pip install pytest pytest-cov pytest-mock requests-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pytest-remotedata
pip install -e .
pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
displayName: 'Test with pytest'

- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Publish test results for Python $(python.version)'

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'
2 changes: 2 additions & 0 deletions ci/requirements-py36-min.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- coveralls
- nose
- pip
- pytables # tables when using pip+PyPI
- pytest
- pytest-cov
- pytest-mock
Expand All @@ -20,3 +21,4 @@ dependencies:
- pytest-rerunfailures # conda version is >3.6
- pytest-remotedata # conda package is 0.3.0, needs > 0.3.1
- requests-mock
- numexpr==2.6.2 # needed for tables, but newest version is not compatible with numpy 1.12
1 change: 1 addition & 0 deletions ci/requirements-py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- defaults
- conda-forge
dependencies:
- blosc=1.14.3 # newest version breaks tables (pytables) on windows
- coveralls
- cython
- ephem
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- defaults
- conda-forge
dependencies:
- blosc=1.14.3 # newest version breaks tables (pytables) on windows
- coveralls
- cython
- ephem
Expand Down
3 changes: 2 additions & 1 deletion docs/sphinx/source/whatsnew/v0.9.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ Documentation

Requirements
~~~~~~~~~~~~
* ``dataclasses`` is required for python 3.6
* ``dataclasses`` is required for python 3.6 (:pull:`1076`)
* ``tables`` is now required instead of optional (:issue:`1286`, :pull:`1287`)

Contributors
~~~~~~~~~~~~
Expand Down
8 changes: 1 addition & 7 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pandas as pd
from scipy.optimize import minimize_scalar
from scipy.linalg import hankel
import tables

from pvlib import atmosphere, tools

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

try:
import tables
except ImportError:
raise ImportError('The Linke turbidity lookup table requires tables. '
'You can still use clearsky.ineichen if you '
'supply your own turbidities.')

if filepath is None:
pvlib_path = os.path.dirname(os.path.abspath(__file__))
filepath = os.path.join(pvlib_path, 'data', 'LinkeTurbidities.h5')
Expand Down
9 changes: 0 additions & 9 deletions pvlib/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ def assert_frame_equal(left, right, **kwargs):
not has_statsmodels, reason='requires statsmodels')


try:
import tables
has_tables = True
except ImportError:
has_tables = False

requires_tables = pytest.mark.skipif(not has_tables, reason='requires tables')


try:
import ephem
has_ephem = True
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 @@ -16,7 +16,7 @@
from pvlib import atmosphere
from pvlib import irradiance

from .conftest import requires_tables, DATA_DIR
from .conftest import DATA_DIR


def test_ineichen_series():
Expand Down Expand Up @@ -189,7 +189,6 @@ def test_ineichen_altitude():
assert_frame_equal(expected, out)


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


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


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


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


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


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


@requires_tables
def test_linke_turbidity_corners():
"""Test Linke turbidity corners out of bounds."""
months = pd.DatetimeIndex('%d/1/2016' % (m + 1) for m in range(12))
Expand Down
3 changes: 1 addition & 2 deletions pvlib/tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pvlib.location import Location
from pvlib.solarposition import declination_spencer71
from pvlib.solarposition import equation_of_time_spencer71
from .conftest import requires_ephem, requires_tables
from .conftest import requires_ephem


def test_location_required():
Expand Down Expand Up @@ -77,7 +77,6 @@ def times():
freq='3H')


@requires_tables
def test_get_clearsky(mocker, times):
tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson')
m = mocker.spy(pvlib.clearsky, 'ineichen')
Expand Down
6 changes: 1 addition & 5 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .conftest import assert_series_equal, assert_frame_equal
import pytest

from .conftest import fail_on_pvlib_version, requires_tables
from .conftest import fail_on_pvlib_version


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


@requires_tables
def test_basic_chain_alt_az(sam_data, cec_inverter_parameters,
sapm_temperature_cs5p_220m):
times = pd.date_range(start='20160101 1200-0700',
Expand All @@ -1810,7 +1809,6 @@ def test_basic_chain_alt_az(sam_data, cec_inverter_parameters,
assert_series_equal(ac, expected)


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


@requires_tables
def test_complete_irradiance(sapm_dc_snl_ac_system, location):
"""Check calculations"""
mc = ModelChain(sapm_dc_snl_ac_system, location)
Expand Down Expand Up @@ -1890,7 +1887,6 @@ def test_complete_irradiance(sapm_dc_snl_ac_system, location):

@pytest.mark.filterwarnings("ignore:This function is not safe at the moment")
@pytest.mark.parametrize("input_type", [tuple, list])
@requires_tables
def test_complete_irradiance_arrays(
sapm_dc_snl_ac_system_same_arrays, location, input_type):
"""ModelChain.complete_irradiance can accept a tuple of weather
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
'pandas >= 0.22.0',
'pytz',
'requests',
'scipy >= 1.2.0']
'scipy >= 1.2.0',
'tables']

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