|
22 | 22 | _new_tile_id,
|
23 | 23 | )
|
24 | 24 |
|
25 |
| -from . import assert_equal, assert_identical, raises_regex |
| 25 | +from . import assert_equal, assert_identical, raises_regex, requires_cftime |
26 | 26 | from .test_dataset import create_test_data
|
27 | 27 |
|
28 | 28 |
|
@@ -877,3 +877,25 @@ def test_auto_combine_without_coords(self):
|
877 | 877 | objs = [Dataset({"foo": ("x", [0])}), Dataset({"foo": ("x", [1])})]
|
878 | 878 | with pytest.warns(FutureWarning, match="supplied do not have global"):
|
879 | 879 | auto_combine(objs)
|
| 880 | + |
| 881 | + |
| 882 | +@requires_cftime |
| 883 | +def test_combine_by_coords_distant_cftime_dates(): |
| 884 | + # Regression test for https://github.com/pydata/xarray/issues/3535 |
| 885 | + import cftime |
| 886 | + |
| 887 | + time_1 = [cftime.DatetimeGregorian(4500, 12, 31)] |
| 888 | + time_2 = [cftime.DatetimeGregorian(4600, 12, 31)] |
| 889 | + time_3 = [cftime.DatetimeGregorian(5100, 12, 31)] |
| 890 | + |
| 891 | + da_1 = DataArray([0], dims=["time"], coords=[time_1], name="a").to_dataset() |
| 892 | + da_2 = DataArray([1], dims=["time"], coords=[time_2], name="a").to_dataset() |
| 893 | + da_3 = DataArray([2], dims=["time"], coords=[time_3], name="a").to_dataset() |
| 894 | + |
| 895 | + result = combine_by_coords([da_1, da_2, da_3]) |
| 896 | + |
| 897 | + expected_time = np.concatenate([time_1, time_2, time_3]) |
| 898 | + expected = DataArray( |
| 899 | + [0, 1, 2], dims=["time"], coords=[expected_time], name="a" |
| 900 | + ).to_dataset() |
| 901 | + assert_identical(result, expected) |
0 commit comments