Skip to content

more upstream-dev cftime failures #3751

@dcherian

Description

@dcherian

https://dev.azure.com/xarray/xarray/_build/results?buildId=2116&view=logs&jobId=2280efed-fda1-53bd-9213-1fa8ec9b4fa8&j=2280efed-fda1-53bd-9213-1fa8ec9b4fa8&t=175181ee-1928-5a6b-f537-168f7a8b7c2d

46 failed tests but they all seem to result from the same TypeError

=================================== FAILURES =================================== ______________ test_sel_date_scalar_nearest[365_day-sel_kwargs0] _______________ da = <xarray.DataArray (time: 4)> 0002-02-01 00:00:00], dtype='object') sel_kwargs = {'method': 'nearest'} @requires_cftime @pytest.mark.parametrize( "sel_kwargs", [{"method": "nearest"}, {"method": "nearest", "tolerance": timedelta(days=70)}], ) def test_sel_date_scalar_nearest(da, date_type, index, sel_kwargs): expected = xr.DataArray(2).assign_coords(time=index[1]) > result = da.sel(time=date_type(1, 4, 1), **sel_kwargs) xarray/tests/test_cftimeindex.py:460: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ xarray/core/dataarray.py:1056: in sel ds = self._to_temp_dataset().sel( xarray/core/dataset.py:2056: in sel pos_indexers, new_indexes = remap_label_indexers( xarray/core/coordinates.py:391: in remap_label_indexers pos_indexers, new_indexes = indexing.remap_label_indexers( xarray/core/indexing.py:270: in remap_label_indexers idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance) xarray/core/indexing.py:189: in convert_label_indexer indexer = index.get_loc( xarray/coding/cftimeindex.py:334: in get_loc return pd.Index.get_loc(self, key, method=method, tolerance=tolerance) /usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/pandas/core/indexes/base.py:2899: in get_loc indexer = self.get_indexer([key], method=method, tolerance=tolerance) /usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/pandas/core/indexes/base.py:2992: in get_indexer indexer = self._get_nearest_indexer(target, limit, tolerance) /usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/pandas/core/indexes/base.py:3076: in _get_nearest_indexer left_distances = np.abs(self[left_indexer] - target) xarray/coding/cftimeindex.py:444: in __sub__ return CFTimeIndex(np.array(self) - other) xarray/coding/cftimeindex.py:248: in __new__ assert_all_valid_date_type(data) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ data = TimedeltaIndex(['-59 days'], dtype='timedelta64[ns]', freq=None) def assert_all_valid_date_type(data): import cftime if len(data) > 0: sample = data[0] date_type = type(sample) if not isinstance(sample, cftime.datetime): > raise TypeError( "CFTimeIndex requires cftime.datetime " "objects. Got object of {}.".format(date_type) ) E TypeError: CFTimeIndex requires cftime.datetime objects. Got object of <class 'pandas._libs.tslibs.timedeltas.Timedelta'>. xarray/coding/cftimeindex.py:206: TypeError 

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