Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbusecke committed Feb 5, 2019
1 parent b67f532 commit 0479829
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions ci/requirements-py37-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ channels:
dependencies:
- python=3.7
- cftime
- nc-time-axis
- dask
- distributed
- h5py
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ channels:
dependencies:
- python=3.7
- cftime
- nc-time-axis
- dask
- distributed
- h5py
Expand Down
22 changes: 1 addition & 21 deletions xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
import pandas as pd

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


# def _convert_cftime_data(values):
# converted = [CalendarDateTime(v, v.calendar) for v in values]
# return converted


# def _convert_all_cftime(da):
# try:
# from cftime import datetime as cftime_datetime
# except ImportError:
# raise ImportError('cftime package missing')
# da = da.copy()
# # find the dim that has a cftime datatype
# dims = set(da.dims)
# cftime_dims = [d for d in dims if isinstance(da[d].data.ravel()[0],
# cftime_datetime)]
# for cd in cftime_dims:
# da[cd].data = _convert_cftime_data(da[cd].data)
# return da


def plot(darray, row=None, col=None, col_wrap=None, ax=None, hue=None,
rtol=0.01, subplot_kws=None, **kwargs):
"""
Expand Down
1 change: 1 addition & 0 deletions xarray/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def LooseVersion(vstring):
has_pynio, requires_pynio = _importorskip('Nio')
has_pseudonetcdf, requires_pseudonetcdf = _importorskip('PseudoNetCDF')
has_cftime, requires_cftime = _importorskip('cftime')
has_nc_time_axis, requires_nc_time_axis = _importorskip('nc_time_axis')
has_cftime_1_0_2_1, requires_cftime_1_0_2_1 = _importorskip(
'cftime', minversion='1.0.2.1')
has_dask, requires_dask = _importorskip('dask')
Expand Down
29 changes: 28 additions & 1 deletion xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

from . import (
assert_array_equal, assert_equal, raises_regex, requires_cftime,
requires_matplotlib, requires_matplotlib2, requires_seaborn)
requires_matplotlib, requires_matplotlib2, requires_seaborn,
requires_nc_time_axis,
)

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


@requires_nc_time_axis
@requires_cftime
class TestCFDatetimePlot(PlotTestCase):
@pytest.fixture(autouse=True)
def setUp(self):
'''
Create a DataArray with a time-axis that contains cftime.datetime64
objects.
'''
month = np.arange(1, 13, 1)
data = np.sin(2 * np.pi * month / 12.0)

darray = DataArray(data, dims=['time'])
darray.coords['time'] = xr.cftime_range(start='2017',
periods=12,
freq='1M',
calendar='noleap')

self.darray = darray

def test_cfdatetime_line_plot(self):
# test if line plot raises no Exception
self.darray.plot.line()


@requires_seaborn
def test_import_seaborn_no_warning():
# GH1633
Expand Down

0 comments on commit 0479829

Please sign in to comment.