Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures with pandas master #3673

Closed
dcherian opened this issue Jan 8, 2020 · 11 comments
Closed

Test failures with pandas master #3673

dcherian opened this issue Jan 8, 2020 · 11 comments

Comments

@dcherian
Copy link
Contributor

dcherian commented Jan 8, 2020

https://dev.azure.com/xarray/xarray/_build/results?buildId=1859&view=logs&jobId=41d90575-019f-5cfd-d78e-c2adebf9a30b&j=41d90575-019f-5cfd-d78e-c2adebf9a30b

2020-01-07T19:19:39.0297443Z =================================== FAILURES ===================================
2020-01-07T19:19:39.0495451Z _________________ test_timedeltaindex_add_cftimeindex[365_day] _________________
2020-01-07T19:19:39.0496702Z 
2020-01-07T19:19:39.0498391Z calendar = '365_day'
2020-01-07T19:19:39.0499052Z 
2020-01-07T19:19:39.0500036Z     @requires_cftime
2020-01-07T19:19:39.0500669Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0501986Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0502556Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0503384Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0503635Z         result = deltas + a
2020-01-07T19:19:39.0504330Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0505283Z         assert result.equals(expected)
2020-01-07T19:19:39.0506265Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0507151Z E       AssertionError: assert False
2020-01-07T19:19:39.0508329Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)
2020-01-07T19:19:39.0509344Z 
2020-01-07T19:19:39.0510351Z xarray/tests/test_cftimeindex.py:724: AssertionError
2020-01-07T19:19:39.0510935Z _________________ test_timedeltaindex_add_cftimeindex[360_day] _________________
2020-01-07T19:19:39.0511748Z 
2020-01-07T19:19:39.0513201Z calendar = '360_day'
2020-01-07T19:19:39.0513958Z 
2020-01-07T19:19:39.0514197Z     @requires_cftime
2020-01-07T19:19:39.0515571Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0517319Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0517575Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0517798Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0519155Z         result = deltas + a
2020-01-07T19:19:39.0519385Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0519619Z         assert result.equals(expected)
2020-01-07T19:19:39.0520075Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0520252Z E       AssertionError: assert False
2020-01-07T19:19:39.0520850Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)
2020-01-07T19:19:39.0521907Z 
2020-01-07T19:19:39.0522818Z xarray/tests/test_cftimeindex.py:724: AssertionError
2020-01-07T19:19:39.0523212Z _________________ test_timedeltaindex_add_cftimeindex[julian] __________________
2020-01-07T19:19:39.0524673Z 
2020-01-07T19:19:39.0525157Z calendar = 'julian'
2020-01-07T19:19:39.0525992Z 
2020-01-07T19:19:39.0526232Z     @requires_cftime
2020-01-07T19:19:39.0526834Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0531142Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0531602Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0531897Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0532131Z         result = deltas + a
2020-01-07T19:19:39.0532351Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0532597Z         assert result.equals(expected)
2020-01-07T19:19:39.0532824Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0533279Z E       AssertionError: assert False
2020-01-07T19:19:39.0534006Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)
2020-01-07T19:19:39.0534981Z 
2020-01-07T19:19:39.0535242Z xarray/tests/test_cftimeindex.py:724: AssertionError
2020-01-07T19:19:39.0536707Z ________________ test_timedeltaindex_add_cftimeindex[all_leap] _________________
2020-01-07T19:19:39.0537052Z 
2020-01-07T19:19:39.0538274Z calendar = 'all_leap'
2020-01-07T19:19:39.0538679Z 
2020-01-07T19:19:39.0538864Z     @requires_cftime
2020-01-07T19:19:39.0539011Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0539145Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0539272Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0539413Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0539531Z         result = deltas + a
2020-01-07T19:19:39.0539644Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0539783Z         assert result.equals(expected)
2020-01-07T19:19:39.0539916Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0540048Z E       AssertionError: assert False
2020-01-07T19:19:39.0540781Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)
2020-01-07T19:19:39.0540948Z 
2020-01-07T19:19:39.0541089Z xarray/tests/test_cftimeindex.py:724: AssertionError
2020-01-07T19:19:39.0541346Z _________________ test_timedeltaindex_add_cftimeindex[366_day] _________________
2020-01-07T19:19:39.0541454Z 
2020-01-07T19:19:39.0542123Z calendar = '366_day'
2020-01-07T19:19:39.0542355Z 
2020-01-07T19:19:39.0542476Z     @requires_cftime
2020-01-07T19:19:39.0542613Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0542733Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0542852Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0543006Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0543123Z         result = deltas + a
2020-01-07T19:19:39.0543239Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0543372Z         assert result.equals(expected)
2020-01-07T19:19:39.0543499Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0543616Z E       AssertionError: assert False
2020-01-07T19:19:39.0544641Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)
2020-01-07T19:19:39.0545191Z 
2020-01-07T19:19:39.0545399Z xarray/tests/test_cftimeindex.py:724: AssertionError
2020-01-07T19:19:39.0545554Z ________________ test_timedeltaindex_add_cftimeindex[gregorian] ________________
2020-01-07T19:19:39.0545679Z 
2020-01-07T19:19:39.0546078Z calendar = 'gregorian'
2020-01-07T19:19:39.0546251Z 
2020-01-07T19:19:39.0546622Z     @requires_cftime
2020-01-07T19:19:39.0546774Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0546940Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0547086Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0547379Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0547529Z         result = deltas + a
2020-01-07T19:19:39.0547669Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0547989Z         assert result.equals(expected)
2020-01-07T19:19:39.0548101Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0548210Z E       AssertionError: assert False
2020-01-07T19:19:39.0548869Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)
2020-01-07T19:19:39.0549023Z 
2020-01-07T19:19:39.0549154Z xarray/tests/test_cftimeindex.py:724: AssertionError
2020-01-07T19:19:39.0549296Z ___________ test_timedeltaindex_add_cftimeindex[proleptic_gregorian] ___________
2020-01-07T19:19:39.0549400Z 
2020-01-07T19:19:39.0549680Z calendar = 'proleptic_gregorian'
2020-01-07T19:19:39.0550189Z 
2020-01-07T19:19:39.0550314Z     @requires_cftime
2020-01-07T19:19:39.0550430Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0550568Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0550686Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0550806Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0550946Z         result = deltas + a
2020-01-07T19:19:39.0551062Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0551198Z         assert result.equals(expected)
2020-01-07T19:19:39.0551337Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0551452Z E       AssertionError: assert False
2020-01-07T19:19:39.0552276Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)
2020-01-07T19:19:39.0552425Z 
2020-01-07T19:19:39.0552548Z xarray/tests/test_cftimeindex.py:724: AssertionError
2020-01-07T19:19:39.0552973Z ____ test_cf_datetime_nan[num_dates1-days since 2000-01-01-expected_list1] _____
2020-01-07T19:19:39.0553281Z 
2020-01-07T19:19:39.0553765Z num_dates = [nan, 0], units = 'days since 2000-01-01'
2020-01-07T19:19:39.0554887Z expected_list = ['NaT', '2000-01-01T00:00:00Z']
2020-01-07T19:19:39.0555104Z 
2020-01-07T19:19:39.0555251Z     @arm_xfail
2020-01-07T19:19:39.0555406Z     @requires_cftime
2020-01-07T19:19:39.0555551Z     @pytest.mark.parametrize(
2020-01-07T19:19:39.0555693Z         ["num_dates", "units", "expected_list"],
2020-01-07T19:19:39.0555849Z         [
2020-01-07T19:19:39.0556225Z             ([np.nan], "days since 2000-01-01", ["NaT"]),
2020-01-07T19:19:39.0556674Z             ([np.nan, 0], "days since 2000-01-01", ["NaT", "2000-01-01T00:00:00Z"]),
2020-01-07T19:19:39.0556881Z             (
2020-01-07T19:19:39.0557026Z                 [np.nan, 0, 1],
2020-01-07T19:19:39.0557374Z                 "days since 2000-01-01",
2020-01-07T19:19:39.0558208Z                 ["NaT", "2000-01-01T00:00:00Z", "2000-01-02T00:00:00Z"],
2020-01-07T19:19:39.0558355Z             ),
2020-01-07T19:19:39.0558466Z         ],
2020-01-07T19:19:39.0558591Z     )
2020-01-07T19:19:39.0559984Z     def test_cf_datetime_nan(num_dates, units, expected_list):
2020-01-07T19:19:39.0560153Z         with warnings.catch_warnings():
2020-01-07T19:19:39.0560559Z             warnings.filterwarnings("ignore", "All-NaN")
2020-01-07T19:19:39.0560733Z             actual = coding.times.decode_cf_datetime(num_dates, units)
2020-01-07T19:19:39.0561076Z         # use pandas because numpy will deprecate timezone-aware conversions
2020-01-07T19:19:39.0561235Z         expected = pd.to_datetime(expected_list)
2020-01-07T19:19:39.0561532Z >       assert_array_equal(expected, actual)
2020-01-07T19:19:39.0561669Z E       AssertionError: 
2020-01-07T19:19:39.0561785Z E       Arrays are not equal
2020-01-07T19:19:39.0561899Z E       
2020-01-07T19:19:39.0562138Z E       Mismatched elements: 2 / 2 (100%)
2020-01-07T19:19:39.0562505Z E        x: array([NaT, Timestamp('2000-01-01 00:00:00+0000', tz='UTC')], dtype=object)
2020-01-07T19:19:39.0563375Z E        y: array([                          'NaT', '2000-01-01T00:00:00.000000000'],
2020-01-07T19:19:39.0563710Z E             dtype='datetime64[ns]')
2020-01-07T19:19:39.0564285Z 
2020-01-07T19:19:39.0564914Z xarray/tests/test_coding_times.py:455: AssertionError
2020-01-07T19:19:39.0565686Z ____ test_cf_datetime_nan[num_dates2-days since 2000-01-01-expected_list2] _____
2020-01-07T19:19:39.0565858Z 
2020-01-07T19:19:39.0566229Z num_dates = [nan, 0, 1], units = 'days since 2000-01-01'
2020-01-07T19:19:39.0566709Z expected_list = ['NaT', '2000-01-01T00:00:00Z', '2000-01-02T00:00:00Z']
2020-01-07T19:19:39.0566894Z 
2020-01-07T19:19:39.0567039Z     @arm_xfail
2020-01-07T19:19:39.0567178Z     @requires_cftime
2020-01-07T19:19:39.0567320Z     @pytest.mark.parametrize(
2020-01-07T19:19:39.0567486Z         ["num_dates", "units", "expected_list"],
2020-01-07T19:19:39.0567660Z         [
2020-01-07T19:19:39.0568035Z             ([np.nan], "days since 2000-01-01", ["NaT"]),
2020-01-07T19:19:39.0568760Z             ([np.nan, 0], "days since 2000-01-01", ["NaT", "2000-01-01T00:00:00Z"]),
2020-01-07T19:19:39.0569295Z             (
2020-01-07T19:19:39.0569436Z                 [np.nan, 0, 1],
2020-01-07T19:19:39.0569737Z                 "days since 2000-01-01",
2020-01-07T19:19:39.0570253Z                 ["NaT", "2000-01-01T00:00:00Z", "2000-01-02T00:00:00Z"],
2020-01-07T19:19:39.0570426Z             ),
2020-01-07T19:19:39.0570560Z         ],
2020-01-07T19:19:39.0570962Z     )
2020-01-07T19:19:39.0571083Z     def test_cf_datetime_nan(num_dates, units, expected_list):
2020-01-07T19:19:39.0571247Z         with warnings.catch_warnings():
2020-01-07T19:19:39.0571569Z             warnings.filterwarnings("ignore", "All-NaN")
2020-01-07T19:19:39.0571732Z             actual = coding.times.decode_cf_datetime(num_dates, units)
2020-01-07T19:19:39.0572075Z         # use pandas because numpy will deprecate timezone-aware conversions
2020-01-07T19:19:39.0572306Z         expected = pd.to_datetime(expected_list)
2020-01-07T19:19:39.0572449Z >       assert_array_equal(expected, actual)
2020-01-07T19:19:39.0572573Z E       AssertionError: 
2020-01-07T19:19:39.0572694Z E       Arrays are not equal
2020-01-07T19:19:39.0572812Z E       
2020-01-07T19:19:39.0572933Z E       Mismatched elements: 3 / 3 (100%)
2020-01-07T19:19:39.0573443Z E        x: array([NaT, Timestamp('2000-01-01 00:00:00+0000', tz='UTC'),
2020-01-07T19:19:39.0573826Z E              Timestamp('2000-01-02 00:00:00+0000', tz='UTC')], dtype=object)
2020-01-07T19:19:39.0575539Z E        y: array([                          'NaT', '2000-01-01T00:00:00.000000000',
2020-01-07T19:19:39.0576050Z E              '2000-01-02T00:00:00.000000000'], dtype='datetime64[ns]')
2020-01-07T19:19:39.0576213Z 
2020-01-07T19:19:39.0576721Z xarray/tests/test_coding_times.py:455: AssertionError
@spencerkclark
Copy link
Member

So there are two classes of failures here:

  1. With pandas master, adding a CFTimeIndex to a TimedeltaIndex no longer returns a CFTimeIndex; instead it returns a generic Index of cftime objects.
Failure

2020-01-07T19:19:39.0297443Z =================================== FAILURES ===================================
2020-01-07T19:19:39.0495451Z _________________ test_timedeltaindex_add_cftimeindex[365_day] _________________
2020-01-07T19:19:39.0496702Z 
2020-01-07T19:19:39.0498391Z calendar = '365_day'
2020-01-07T19:19:39.0499052Z 
2020-01-07T19:19:39.0500036Z     @requires_cftime
2020-01-07T19:19:39.0500669Z     @pytest.mark.parametrize("calendar", _CFTIME_CALENDARS)
2020-01-07T19:19:39.0501986Z     def test_timedeltaindex_add_cftimeindex(calendar):
2020-01-07T19:19:39.0502556Z         a = xr.cftime_range("2000", periods=5, calendar=calendar)
2020-01-07T19:19:39.0503384Z         deltas = pd.TimedeltaIndex([timedelta(days=2) for _ in range(5)])
2020-01-07T19:19:39.0503635Z         result = deltas + a
2020-01-07T19:19:39.0504330Z         expected = a.shift(2, "D")
2020-01-07T19:19:39.0505283Z         assert result.equals(expected)
2020-01-07T19:19:39.0506265Z >       assert isinstance(result, CFTimeIndex)
2020-01-07T19:19:39.0507151Z E       AssertionError: assert False
2020-01-07T19:19:39.0508329Z E        +  where False = isinstance(Index([2000-01-03 00:00:00, 2000-01-04 00:00:00, 2000-01-05 00:00:00,\n       2000-01-06 00:00:00, 2000-01-07 00:00:00],\n      dtype='object'), CFTimeIndex)

  1. With pandas master, casting a DatetimeIndex (i.e. the result of a call to to_datetime) to an array now returns a NumPy array of timezone-aware Timestamp objects, rather than timezone-naive NumPy array of dtype datetime64[ns].
Failure

2020-01-07T19:19:39.0552973Z ____ test_cf_datetime_nan[num_dates1-days since 2000-01-01-expected_list1] _____
2020-01-07T19:19:39.0553281Z 
2020-01-07T19:19:39.0553765Z num_dates = [nan, 0], units = 'days since 2000-01-01'
2020-01-07T19:19:39.0554887Z expected_list = ['NaT', '2000-01-01T00:00:00Z']
2020-01-07T19:19:39.0555104Z 
2020-01-07T19:19:39.0555251Z     @arm_xfail
2020-01-07T19:19:39.0555406Z     @requires_cftime
2020-01-07T19:19:39.0555551Z     @pytest.mark.parametrize(
2020-01-07T19:19:39.0555693Z         ["num_dates", "units", "expected_list"],
2020-01-07T19:19:39.0555849Z         [
2020-01-07T19:19:39.0556225Z             ([np.nan], "days since 2000-01-01", ["NaT"]),
2020-01-07T19:19:39.0556674Z             ([np.nan, 0], "days since 2000-01-01", ["NaT", "2000-01-01T00:00:00Z"]),
2020-01-07T19:19:39.0556881Z             (
2020-01-07T19:19:39.0557026Z                 [np.nan, 0, 1],
2020-01-07T19:19:39.0557374Z                 "days since 2000-01-01",
2020-01-07T19:19:39.0558208Z                 ["NaT", "2000-01-01T00:00:00Z", "2000-01-02T00:00:00Z"],
2020-01-07T19:19:39.0558355Z             ),
2020-01-07T19:19:39.0558466Z         ],
2020-01-07T19:19:39.0558591Z     )
2020-01-07T19:19:39.0559984Z     def test_cf_datetime_nan(num_dates, units, expected_list):
2020-01-07T19:19:39.0560153Z         with warnings.catch_warnings():
2020-01-07T19:19:39.0560559Z             warnings.filterwarnings("ignore", "All-NaN")
2020-01-07T19:19:39.0560733Z             actual = coding.times.decode_cf_datetime(num_dates, units)
2020-01-07T19:19:39.0561076Z         # use pandas because numpy will deprecate timezone-aware conversions
2020-01-07T19:19:39.0561235Z         expected = pd.to_datetime(expected_list)
2020-01-07T19:19:39.0561532Z >       assert_array_equal(expected, actual)
2020-01-07T19:19:39.0561669Z E       AssertionError: 
2020-01-07T19:19:39.0561785Z E       Arrays are not equal
2020-01-07T19:19:39.0561899Z E       
2020-01-07T19:19:39.0562138Z E       Mismatched elements: 2 / 2 (100%)
2020-01-07T19:19:39.0562505Z E        x: array([NaT, Timestamp('2000-01-01 00:00:00+0000', tz='UTC')], dtype=object)
2020-01-07T19:19:39.0563375Z E        y: array([                          'NaT', '2000-01-01T00:00:00.000000000'],
2020-01-07T19:19:39.0563710Z E             dtype='datetime64[ns]')
2020-01-07T19:19:39.0564285Z 
2020-01-07T19:19:39.0564914Z xarray/tests/test_coding_times.py:455: AssertionError

(2) is simple. Basically due to a planned change1 in pandas, the test needs to be edited. In xarray we still expect decode_cf_datetime to return timezone-naive dates. Therefore we need to make sure that we are comparing against a timezone-naive reference.

(1) is trickier; I'm not sure if it's something we should raise in the pandas issue tracker. Essentially we rely on TimedeltaIndex.__add__(other) to return NotImplemented when other is a CFTimeIndex; this way it will resort to using CFTimeIndex.__radd__ instead. It looks like recent code changes in pandas broke this.


1See this FutureWarning:

FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive ndarray with 'datetime64[ns]' dtype. In the future, this will return an ndarray with 'object' dtype where each element is a 'pandas.Timestamp' with the correct 'tz'.
	To accept the future behavior, pass 'dtype=object'.
	To keep the old behavior, pass 'dtype="datetime64[ns]"'.
  exec(code_obj, self.user_global_ns, self.user_ns)

@spencerkclark spencerkclark changed the title test failure with cftime 1.1.0 Test failures with pandas master Jan 12, 2020
@dcherian
Copy link
Contributor Author

(1) is trickier; I'm not sure if it's something we should raise in the pandas issue tracker. Essentially we rely on TimedeltaIndex.add(other) to return NotImplemented when other is a CFTimeIndex; this way it will resort to using CFTimeIndex.radd instead. It looks like recent code changes in pandas broke this.

cc @TomAugspurger

@TomAugspurger
Copy link
Contributor

@jbrockmendel likely knows more about the index arithmetic issue.

 In [22]: import xarray as xr

In [23]: import pandas as pd

In [24]: idx = pd.timedelta_range("1D", periods=5, freq="D")

In [25]: a = xr.cftime_range("2000", periods=5)

In [26]: idx + a
/Users/taugspurger/sandbox/pandas/pandas/core/arrays/datetimelike.py:1204: PerformanceWarning: Adding/subtracting array of DateOffsets to TimedeltaArray not vectorized
  PerformanceWarning,
Out[26]:
Index([2000-01-02 00:00:00, 2000-01-04 00:00:00, 2000-01-06 00:00:00,
       2000-01-08 00:00:00, 2000-01-10 00:00:00],
      dtype='object')

In [27]: a + idx
Out[27]:
CFTimeIndex([2000-01-02 00:00:00, 2000-01-04 00:00:00, 2000-01-06 00:00:00,
             2000-01-08 00:00:00, 2000-01-10 00:00:00],
            dtype='object')

@jbrockmendel
Copy link

we recently changed datetimelike arithmetic to send all object-dtype arrays through _addsub_object_array (previously _addsub_offsetlike). Previously I think idx.__add__(a) would return NotImplemented. So we probably want to get the NotImplemented behavior back.

@dcherian
Copy link
Contributor Author

Thanks @jbrockmendel should we open a pandas issue?

@dcherian dcherian mentioned this issue Jan 17, 2020
11 tasks
@TomAugspurger
Copy link
Contributor

Opened pandas-dev/pandas#31109.

@dcherian
Copy link
Contributor Author

Thanks @TomAugspurger

@keewis keewis mentioned this issue Jan 22, 2020
3 tasks
@dcherian
Copy link
Contributor Author

should be closed by pandas-dev/pandas#31136 . I think the tests will turn green once the wheels update

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Jan 28, 2020 via email

@spencerkclark
Copy link
Member

Thanks for the fixes @TomAugspurger!

@dcherian
Copy link
Contributor Author

all green! (https://github.com/pydata/xarray/runs/415513689) Thanks Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants