Skip to content

BUG: constrain cftime to >=1.1.1 #947

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 22 commits into from
Apr 13, 2020
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
4 changes: 4 additions & 0 deletions docs/sphinx/source/whatsnew/v0.7.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Documentation
Requirements
~~~~~~~~~~~~
* nrel-pysam (optional) minimum set to v1.0.0 (:issue:`874`)
* cftime (optional) minimum set to >=1.1.1. Use of
`only_use_python_datetimes` kwarg in `netCDF4.num2date` in forecast.py
requires >=1.1.1 which is >=Python3.6. (:pull:`947`)

Contributors
~~~~~~~~~~~~
Expand All @@ -89,3 +92,4 @@ Contributors
* Siyan (Veronica) Guo (:ghuser:`veronicaguo`)
* Eric Fitch (:ghuser:`ericf900`)
* Joseph Palakapilly (:ghuser:`JPalakapilly`)
* Auguste Colle(:ghuser:`augustecolle`)
3 changes: 2 additions & 1 deletion pvlib/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def set_time(self, time):
pandas.DatetimeIndex
'''
times = num2date(time[:].squeeze(), time.units,
only_use_cftime_datetimes=False)
only_use_cftime_datetimes=False,
only_use_python_datetimes=True)
self.time = pd.DatetimeIndex(pd.Series(times), tz=self.location.tz)

def cloud_cover_to_ghi_linear(self, cloud_cover, ghi_clear, offset=35,
Expand Down
14 changes: 14 additions & 0 deletions pvlib/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ def has_numba():
requires_pysam = pytest.mark.skipif(not has_pysam, reason="requires PySAM")


try:
import cftime # noqa: F401

has_recent_cftime = parse_version(cftime.__version__) > parse_version(
"1.1.0"
)
except ImportError:
has_recent_cftime = False

requires_recent_cftime = pytest.mark.skipif(
not has_recent_cftime, reason="requires cftime > 1.1.0"
)


@pytest.fixture(scope="session")
def sam_data():
data = {}
Expand Down
14 changes: 13 additions & 1 deletion pvlib/tests/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
import pytest
from numpy.testing import assert_allclose

from conftest import requires_siphon, has_siphon, skip_windows
from conftest import (
requires_siphon,
has_siphon,
skip_windows,
requires_recent_cftime,
)
from conftest import RERUNS, RERUNS_DELAY

pytestmark = pytest.mark.skipif(not has_siphon, reason='requires siphon')
Expand Down Expand Up @@ -60,6 +65,7 @@ def model(request):


@requires_siphon
@requires_recent_cftime
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_process_data(model):
Expand All @@ -78,6 +84,7 @@ def test_process_data(model):


@requires_siphon
@requires_recent_cftime
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_bad_kwarg_get_data():
Expand All @@ -90,6 +97,7 @@ def test_bad_kwarg_get_data():


@requires_siphon
@requires_recent_cftime
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_bad_kwarg_get_processed_data():
Expand All @@ -102,6 +110,7 @@ def test_bad_kwarg_get_processed_data():


@requires_siphon
@requires_recent_cftime
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_how_kwarg_get_processed_data():
Expand All @@ -112,6 +121,7 @@ def test_how_kwarg_get_processed_data():


@requires_siphon
@requires_recent_cftime
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_vert_level():
Expand All @@ -122,6 +132,7 @@ def test_vert_level():


@requires_siphon
@requires_recent_cftime
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_datetime():
Expand All @@ -132,6 +143,7 @@ def test_datetime():


@requires_siphon
@requires_recent_cftime
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_queryvariables():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
'pytest-timeout', 'pytest-rerunfailures', 'pytest-remotedata']
EXTRAS_REQUIRE = {
'optional': ['ephem', 'cython', 'netcdf4', 'nrel-pysam', 'numba',
'pvfactors', 'scipy', 'siphon', 'tables'],
'pvfactors', 'scipy', 'siphon', 'tables', 'cftime >= 1.1.1'],
'doc': ['ipython', 'matplotlib', 'sphinx == 1.8.5', 'sphinx_rtd_theme',
'sphinx-gallery', 'docutils == 0.15.2'],
'test': TESTS_REQUIRE
Expand Down