Skip to content

Test Failure: test_datetime_line_plot #1813

@jhamman

Description

@jhamman

We're getting a single test failure in the plot tests on master (link to travis failure. I haven't been able to reproduce this locally yet so I'm just going to post here to see if anyone has any ideas.

Code Sample

___________________ TestDatetimePlot.test_datetime_line_plot ___________________
self = <xarray.tests.test_plot.TestDatetimePlot testMethod=test_datetime_line_plot>
    def test_datetime_line_plot(self):
        # test if line plot raises no Exception
>       self.darray.plot.line()
xarray/tests/test_plot.py:1333: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
xarray/plot/plot.py:328: in line
    return line(self._da, *args, **kwargs)
xarray/plot/plot.py:223: in line
    _ensure_plottable(x)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
args = (<xarray.DataArray 'time' (time: 12)>
array([datetime.datetime(2017, 1, 1, 0, 0),
       datetime.datetime(2017, 2, 1,... 12, 1, 0, 0)], dtype=object)
Coordinates:
  * time     (time) object 2017-01-01 2017-02-01 2017-03-01 2017-04-01 ...,)
numpy_types = [<class 'numpy.floating'>, <class 'numpy.integer'>, <class 'numpy.timedelta64'>, <class 'numpy.datetime64'>]
other_types = [<class 'datetime.datetime'>]
x = <xarray.DataArray 'time' (time: 12)>
array([datetime.datetime(2017, 1, 1, 0, 0),
       datetime.datetime(2017, 2, 1, ...7, 12, 1, 0, 0)], dtype=object)
Coordinates:
  * time     (time) object 2017-01-01 2017-02-01 2017-03-01 2017-04-01 ...
    def _ensure_plottable(*args):
        """
        Raise exception if there is anything in args that can't be plotted on an
        axis.
        """
        numpy_types = [np.floating, np.integer, np.timedelta64, np.datetime64]
        other_types = [datetime]
    
        for x in args:
            if not (_valid_numpy_subdtype(np.array(x), numpy_types)
                    or _valid_other_type(np.array(x), other_types)):
>               raise TypeError('Plotting requires coordinates to be numeric '
                                'or dates.')
E               TypeError: Plotting requires coordinates to be numeric or dates.
xarray/plot/plot.py:57: TypeError

Expected Output

This test was previously passing

Output of xr.show_versions()

https://travis-ci.org/pydata/xarray/jobs/326640013#L1262

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions