Skip to content

Commit 0479829

Browse files
committed
added tests
1 parent b67f532 commit 0479829

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

ci/requirements-py37-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ channels:
44
dependencies:
55
- python=3.7
66
- cftime
7+
- nc-time-axis
78
- dask
89
- distributed
910
- h5py

ci/requirements-py37.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ channels:
44
dependencies:
55
- python=3.7
66
- cftime
7+
- nc-time-axis
78
- dask
89
- distributed
910
- h5py

xarray/plot/plot.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
import pandas as pd
1212

13-
from .facetgrid import FacetGrid
13+
from .facetgrid import _easy_facetgrid
1414
from .utils import (
1515
_add_colorbar, _ensure_plottable, _infer_interval_breaks, _infer_xy_labels,
1616
_interval_to_double_bound_points, _interval_to_mid_points,
@@ -102,26 +102,6 @@ def _infer_line_data(darray, x, y, hue):
102102
return xplt, yplt, hueplt, xlabel, ylabel, huelabel
103103

104104

105-
# def _convert_cftime_data(values):
106-
# converted = [CalendarDateTime(v, v.calendar) for v in values]
107-
# return converted
108-
109-
110-
# def _convert_all_cftime(da):
111-
# try:
112-
# from cftime import datetime as cftime_datetime
113-
# except ImportError:
114-
# raise ImportError('cftime package missing')
115-
# da = da.copy()
116-
# # find the dim that has a cftime datatype
117-
# dims = set(da.dims)
118-
# cftime_dims = [d for d in dims if isinstance(da[d].data.ravel()[0],
119-
# cftime_datetime)]
120-
# for cd in cftime_dims:
121-
# da[cd].data = _convert_cftime_data(da[cd].data)
122-
# return da
123-
124-
125105
def plot(darray, row=None, col=None, col_wrap=None, ax=None, hue=None,
126106
rtol=0.01, subplot_kws=None, **kwargs):
127107
"""

xarray/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def LooseVersion(vstring):
6363
has_pynio, requires_pynio = _importorskip('Nio')
6464
has_pseudonetcdf, requires_pseudonetcdf = _importorskip('PseudoNetCDF')
6565
has_cftime, requires_cftime = _importorskip('cftime')
66+
has_nc_time_axis, requires_nc_time_axis = _importorskip('nc_time_axis')
6667
has_cftime_1_0_2_1, requires_cftime_1_0_2_1 = _importorskip(
6768
'cftime', minversion='1.0.2.1')
6869
has_dask, requires_dask = _importorskip('dask')

xarray/tests/test_plot.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
from . import (
1919
assert_array_equal, assert_equal, raises_regex, requires_cftime,
20-
requires_matplotlib, requires_matplotlib2, requires_seaborn)
20+
requires_matplotlib, requires_matplotlib2, requires_seaborn,
21+
requires_nc_time_axis,
22+
)
2123

2224
# import mpl and change the backend before other mpl imports
2325
try:
@@ -1828,6 +1830,31 @@ def test_datetime_line_plot(self):
18281830
self.darray.plot.line()
18291831

18301832

1833+
@requires_nc_time_axis
1834+
@requires_cftime
1835+
class TestCFDatetimePlot(PlotTestCase):
1836+
@pytest.fixture(autouse=True)
1837+
def setUp(self):
1838+
'''
1839+
Create a DataArray with a time-axis that contains cftime.datetime64
1840+
objects.
1841+
'''
1842+
month = np.arange(1, 13, 1)
1843+
data = np.sin(2 * np.pi * month / 12.0)
1844+
1845+
darray = DataArray(data, dims=['time'])
1846+
darray.coords['time'] = xr.cftime_range(start='2017',
1847+
periods=12,
1848+
freq='1M',
1849+
calendar='noleap')
1850+
1851+
self.darray = darray
1852+
1853+
def test_cfdatetime_line_plot(self):
1854+
# test if line plot raises no Exception
1855+
self.darray.plot.line()
1856+
1857+
18311858
@requires_seaborn
18321859
def test_import_seaborn_no_warning():
18331860
# GH1633

0 commit comments

Comments
 (0)