62
62
)
63
63
from xarray .core .common import _contains_datetime_like_objects , is_np_datetime_like
64
64
from xarray .core .pdcompat import (
65
- NoDefault ,
66
65
count_not_none ,
67
66
nanosecond_precision_timestamp ,
68
- no_default ,
69
67
)
70
68
from xarray .core .utils import attempt_import , emit_user_level_warning
71
69
72
70
if TYPE_CHECKING :
73
- from xarray .core .types import InclusiveOptions , Self , SideOptions , TypeAlias
71
+ from xarray .core .types import InclusiveOptions , Self , TypeAlias
74
72
75
73
76
74
DayOption : TypeAlias = Literal ["start" , "end" ]
@@ -943,51 +941,14 @@ def _generate_range(start, end, periods, offset):
943
941
current = next_date
944
942
945
943
946
- def _translate_closed_to_inclusive (closed ):
947
- """Follows code added in pandas #43504."""
948
- emit_user_level_warning (
949
- "Following pandas, the `closed` parameter is deprecated in "
950
- "favor of the `inclusive` parameter, and will be removed in "
951
- "a future version of xarray." ,
952
- FutureWarning ,
953
- )
954
- if closed is None :
955
- inclusive = "both"
956
- elif closed in ("left" , "right" ):
957
- inclusive = closed
958
- else :
959
- raise ValueError (
960
- f"Argument `closed` must be either 'left', 'right', or None. "
961
- f"Got { closed !r} ."
962
- )
963
- return inclusive
964
-
965
-
966
- def _infer_inclusive (
967
- closed : NoDefault | SideOptions , inclusive : InclusiveOptions | None
968
- ) -> InclusiveOptions :
969
- """Follows code added in pandas #43504."""
970
- if closed is not no_default and inclusive is not None :
971
- raise ValueError (
972
- "Following pandas, deprecated argument `closed` cannot be "
973
- "passed if argument `inclusive` is not None."
974
- )
975
- if closed is not no_default :
976
- return _translate_closed_to_inclusive (closed )
977
- if inclusive is None :
978
- return "both"
979
- return inclusive
980
-
981
-
982
944
def cftime_range (
983
945
start = None ,
984
946
end = None ,
985
947
periods = None ,
986
948
freq = None ,
987
949
normalize = False ,
988
950
name = None ,
989
- closed : NoDefault | SideOptions = no_default ,
990
- inclusive : None | InclusiveOptions = None ,
951
+ inclusive : InclusiveOptions = "both" ,
991
952
calendar = "standard" ,
992
953
) -> CFTimeIndex :
993
954
"""Return a fixed frequency CFTimeIndex.
@@ -1006,16 +967,7 @@ def cftime_range(
1006
967
Normalize start/end dates to midnight before generating date range.
1007
968
name : str, default: None
1008
969
Name of the resulting index
1009
- closed : {None, "left", "right"}, default: "NO_DEFAULT"
1010
- Make the interval closed with respect to the given frequency to the
1011
- "left", "right", or both sides (None).
1012
-
1013
- .. deprecated:: 2023.02.0
1014
- Following pandas, the ``closed`` parameter is deprecated in favor
1015
- of the ``inclusive`` parameter, and will be removed in a future
1016
- version of xarray.
1017
-
1018
- inclusive : {None, "both", "neither", "left", "right"}, default None
970
+ inclusive : {"both", "neither", "left", "right"}, default "both"
1019
971
Include boundaries; whether to set each bound as closed or open.
1020
972
1021
973
.. versionadded:: 2023.02.0
@@ -1193,8 +1145,6 @@ def cftime_range(
1193
1145
offset = to_offset (freq )
1194
1146
dates = np .array (list (_generate_range (start , end , periods , offset )))
1195
1147
1196
- inclusive = _infer_inclusive (closed , inclusive )
1197
-
1198
1148
if inclusive == "neither" :
1199
1149
left_closed = False
1200
1150
right_closed = False
@@ -1229,8 +1179,7 @@ def date_range(
1229
1179
tz = None ,
1230
1180
normalize = False ,
1231
1181
name = None ,
1232
- closed : NoDefault | SideOptions = no_default ,
1233
- inclusive : None | InclusiveOptions = None ,
1182
+ inclusive : InclusiveOptions = "both" ,
1234
1183
calendar = "standard" ,
1235
1184
use_cftime = None ,
1236
1185
):
@@ -1257,20 +1206,10 @@ def date_range(
1257
1206
Normalize start/end dates to midnight before generating date range.
1258
1207
name : str, default: None
1259
1208
Name of the resulting index
1260
- closed : {None, "left", "right"}, default: "NO_DEFAULT"
1261
- Make the interval closed with respect to the given frequency to the
1262
- "left", "right", or both sides (None).
1263
-
1264
- .. deprecated:: 2023.02.0
1265
- Following pandas, the `closed` parameter is deprecated in favor
1266
- of the `inclusive` parameter, and will be removed in a future
1267
- version of xarray.
1268
-
1269
- inclusive : {None, "both", "neither", "left", "right"}, default: None
1209
+ inclusive : {"both", "neither", "left", "right"}, default: "both"
1270
1210
Include boundaries; whether to set each bound as closed or open.
1271
1211
1272
1212
.. versionadded:: 2023.02.0
1273
-
1274
1213
calendar : str, default: "standard"
1275
1214
Calendar type for the datetimes.
1276
1215
use_cftime : boolean, optional
@@ -1294,8 +1233,6 @@ def date_range(
1294
1233
if tz is not None :
1295
1234
use_cftime = False
1296
1235
1297
- inclusive = _infer_inclusive (closed , inclusive )
1298
-
1299
1236
if _is_standard_calendar (calendar ) and use_cftime is not True :
1300
1237
try :
1301
1238
return pd .date_range (
0 commit comments