id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 2279042264,PR_kwDOAMm_X85ui13E,8999,Port negative frequency fix for `pandas.date_range` to `cftime_range`,6628425,open,0,,,0,2024-05-04T14:48:08Z,2024-05-04T14:51:26Z,,MEMBER,,0,pydata/xarray/pulls/8999," Like `pandas.date_range`, `cftime_range` would previously return dates outside the range of the specified start and end dates if provided a negative frequency: ``` >>> start = cftime.DatetimeGregorian(2023, 10, 31) >>> end = cftime.DatetimeGregorian(2021, 11, 1) >>> xr.cftime_range(start, end, freq=""-1YE"") CFTimeIndex([2023-12-31 00:00:00, 2022-12-31 00:00:00, 2021-12-31 00:00:00], dtype='object', length=3, calendar='standard', freq='-1YE-DEC') ``` This PR ports a bug fix from pandas (https://github.com/pandas-dev/pandas/issues/56147) to prevent this from happening. The above example now produces: ``` >>> start = cftime.DatetimeGregorian(2023, 10, 31) >>> end = cftime.DatetimeGregorian(2021, 11, 1) >>> xr.cftime_range(start, end, freq=""-1YE"") CFTimeIndex([2022-12-31 00:00:00, 2021-12-31 00:00:00], dtype='object', length=2, calendar='standard', freq=None) ``` Since this is a bug fix, we do not make any attempt to preserve the old behavior if an earlier version of pandas is installed. In the testing context this means we skip some tests for pandas versions less than 3.0. - [x] User visible changes (including notable bug fixes) are documented in `whats-new.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8999/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 2242197433,PR_kwDOAMm_X85smT4G,8942,WIP: Support calendar-specific `cftime.datetime` instances,6628425,open,0,,,0,2024-04-14T14:33:06Z,2024-04-14T15:41:08Z,,MEMBER,,1,pydata/xarray/pulls/8942," Since cftime version 1.3.0, the base `cftime.datetime` object can be calendar-aware, obviating the need for calendar-specific subclasses like `cftime.DatetimeNoLeap`. This PR aims to finally enable the use of these objects in xarray. We can also use this moment to remove cruft around accommodating inexact cftime datetime arithmetic, since that has been fixed since cftime version 1.2.0. The idea will be to support both for a period of time and eventually drop support for the calendar-specific subclasses. I do not think too much should need to change within xarray—the main challenge will be to see if we can maintain adequate test coverage without multiplying the number of cftime tests by two. This draft PR is at least a start towards that. - [ ] Closes #4336 - [ ] Closes #4853 - [ ] Closes #5551 - [ ] Closes #8298 - [ ] Closes #8941 - [ ] Tests added - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` - [ ] New functions/methods are listed in `api.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8942/reactions"", ""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 1, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull