Skip to content

Commit 73e2e0c

Browse files
BUG: constrain cftime to >=1.1.1 (#947)
* limit cftime to <=1.1.0 for all but Python3.5 * add what's new * Revert "limit cftime to <=1.1.0 for all but Python3.5" This reverts commit 1afd3cb. * add only_use_python_datetimes, switch off only_use_cftime_datetimes * limit cftime>=1.1.1 * update what's new * install cftime from pip instead * selectively fail tests * raise Exception for old cftime * Revert "install cftime from pip instead" This reverts commit 251b221. * limit cftime, skip<python3.6 * fix lint, import sys * set cftime<=1.1.0 * fix test_forecast * add new cftime kwargs, xfail for cftime>1.1.0 * pin to 1.1.1 and above * improve what's new * remove unnecessary conda pinning * remove sys * test not limiting cftime * Revert "test not limiting cftime" This reverts commit f210b11.
1 parent 7bd1a3f commit 73e2e0c

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ Documentation
9191
Requirements
9292
~~~~~~~~~~~~
9393
* nrel-pysam (optional) minimum set to v1.0.0 (:issue:`874`)
94+
* cftime (optional) minimum set to >=1.1.1. Use of
95+
`only_use_python_datetimes` kwarg in `netCDF4.num2date` in forecast.py
96+
requires >=1.1.1 which is >=Python3.6. (:pull:`947`)
9497

9598
Contributors
9699
~~~~~~~~~~~~
@@ -103,3 +106,4 @@ Contributors
103106
* Siyan (Veronica) Guo (:ghuser:`veronicaguo`)
104107
* Eric Fitch (:ghuser:`ericf900`)
105108
* Joseph Palakapilly (:ghuser:`JPalakapilly`)
109+
* Auguste Colle(:ghuser:`augustecolle`)

pvlib/forecast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ def set_time(self, time):
406406
pandas.DatetimeIndex
407407
'''
408408
times = num2date(time[:].squeeze(), time.units,
409-
only_use_cftime_datetimes=False)
409+
only_use_cftime_datetimes=False,
410+
only_use_python_datetimes=True)
410411
self.time = pd.DatetimeIndex(pd.Series(times), tz=self.location.tz)
411412

412413
def cloud_cover_to_ghi_linear(self, cloud_cover, ghi_clear, offset=35,

pvlib/tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ def has_numba():
156156
requires_pysam = pytest.mark.skipif(not has_pysam, reason="requires PySAM")
157157

158158

159+
try:
160+
import cftime # noqa: F401
161+
162+
has_recent_cftime = parse_version(cftime.__version__) > parse_version(
163+
"1.1.0"
164+
)
165+
except ImportError:
166+
has_recent_cftime = False
167+
168+
requires_recent_cftime = pytest.mark.skipif(
169+
not has_recent_cftime, reason="requires cftime > 1.1.0"
170+
)
171+
172+
159173
@pytest.fixture(scope="session")
160174
def sam_data():
161175
data = {}

pvlib/tests/test_forecast.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import pytest
77
from numpy.testing import assert_allclose
88

9-
from conftest import requires_siphon, has_siphon, skip_windows
9+
from conftest import (
10+
requires_siphon,
11+
has_siphon,
12+
skip_windows,
13+
requires_recent_cftime,
14+
)
1015
from conftest import RERUNS, RERUNS_DELAY
1116

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

6166

6267
@requires_siphon
68+
@requires_recent_cftime
6369
@pytest.mark.remote_data
6470
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
6571
def test_process_data(model):
@@ -78,6 +84,7 @@ def test_process_data(model):
7884

7985

8086
@requires_siphon
87+
@requires_recent_cftime
8188
@pytest.mark.remote_data
8289
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
8390
def test_bad_kwarg_get_data():
@@ -90,6 +97,7 @@ def test_bad_kwarg_get_data():
9097

9198

9299
@requires_siphon
100+
@requires_recent_cftime
93101
@pytest.mark.remote_data
94102
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
95103
def test_bad_kwarg_get_processed_data():
@@ -102,6 +110,7 @@ def test_bad_kwarg_get_processed_data():
102110

103111

104112
@requires_siphon
113+
@requires_recent_cftime
105114
@pytest.mark.remote_data
106115
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
107116
def test_how_kwarg_get_processed_data():
@@ -112,6 +121,7 @@ def test_how_kwarg_get_processed_data():
112121

113122

114123
@requires_siphon
124+
@requires_recent_cftime
115125
@pytest.mark.remote_data
116126
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
117127
def test_vert_level():
@@ -122,6 +132,7 @@ def test_vert_level():
122132

123133

124134
@requires_siphon
135+
@requires_recent_cftime
125136
@pytest.mark.remote_data
126137
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
127138
def test_datetime():
@@ -132,6 +143,7 @@ def test_datetime():
132143

133144

134145
@requires_siphon
146+
@requires_recent_cftime
135147
@pytest.mark.remote_data
136148
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
137149
def test_queryvariables():

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
'pytest-timeout', 'pytest-rerunfailures', 'pytest-remotedata']
4646
EXTRAS_REQUIRE = {
4747
'optional': ['ephem', 'cython', 'netcdf4', 'nrel-pysam', 'numba',
48-
'pvfactors', 'scipy', 'siphon', 'tables'],
48+
'pvfactors', 'scipy', 'siphon', 'tables', 'cftime >= 1.1.1'],
4949
'doc': ['ipython', 'matplotlib', 'sphinx == 1.8.5', 'sphinx_rtd_theme',
5050
'sphinx-gallery', 'docutils == 0.15.2'],
5151
'test': TESTS_REQUIRE

0 commit comments

Comments
 (0)