Skip to content

Commit 5ec6f35

Browse files
author
Cameron Stark
committed
add new cftime kwargs, xfail for cftime>1.1.0
1 parent 71acc29 commit 5ec6f35

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

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
@@ -157,6 +157,20 @@ def has_numba():
157157
requires_pysam = pytest.mark.skipif(not has_pysam, reason="requires PySAM")
158158

159159

160+
try:
161+
import cftime # noqa: F401
162+
163+
has_recent_cftime = parse_version(cftime.__version__) > parse_version(
164+
"1.1.0"
165+
)
166+
except ImportError:
167+
has_recent_cftime = False
168+
169+
requires_recent_cftime = pytest.mark.skipif(
170+
not has_recent_cftime, reason="requires cftime > 1.1.0"
171+
)
172+
173+
160174
@pytest.fixture(scope="session")
161175
def sam_data():
162176
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', "cftime <= 1.1.0"],
48+
'pvfactors', 'scipy', 'siphon', 'tables', 'cftime>=1.1.0'],
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)