43
43
44
44
import re
45
45
from datetime import datetime , timedelta
46
- from enum import Enum
47
46
from functools import partial
48
- from typing import TYPE_CHECKING , ClassVar , Literal
47
+ from typing import TYPE_CHECKING , ClassVar
49
48
50
49
import numpy as np
51
50
import pandas as pd
58
57
format_cftime_datetime ,
59
58
)
60
59
from xarray .core .common import _contains_datetime_like_objects , is_np_datetime_like
61
- from xarray .core .pdcompat import count_not_none
60
+ from xarray .core .pdcompat import NoDefault , count_not_none , no_default
62
61
from xarray .core .utils import emit_user_level_warning
63
62
64
63
try :
@@ -855,29 +854,6 @@ def _generate_range(start, end, periods, offset):
855
854
current = next_date
856
855
857
856
858
- class _NoDefault (Enum ):
859
- """Used by pandas to specify a default value for a deprecated argument.
860
- Copied from pandas._libs.lib._NoDefault.
861
-
862
- See also:
863
- - pandas-dev/pandas#30788
864
- - pandas-dev/pandas#40684
865
- - pandas-dev/pandas#40715
866
- - pandas-dev/pandas#47045
867
- """
868
-
869
- no_default = "NO_DEFAULT"
870
-
871
- def __repr__ (self ) -> str :
872
- return "<no_default>"
873
-
874
-
875
- no_default = (
876
- _NoDefault .no_default
877
- ) # Sentinel indicating the default value following pandas
878
- NoDefault = Literal [_NoDefault .no_default ] # For typing following pandas
879
-
880
-
881
857
def _translate_closed_to_inclusive (closed ):
882
858
"""Follows code added in pandas #43504."""
883
859
emit_user_level_warning (
@@ -939,12 +915,11 @@ def cftime_range(
939
915
Normalize start/end dates to midnight before generating date range.
940
916
name : str, default: None
941
917
Name of the resulting index
942
- closed : {"left", "right"} or None , default: "NO_DEFAULT"
918
+ closed : {None, "left", "right"}, default: "NO_DEFAULT"
943
919
Make the interval closed with respect to the given frequency to the
944
920
"left", "right", or both sides (None).
945
921
946
922
.. deprecated:: 2023.01.1
947
-
948
923
Following pandas, the ``closed`` parameter is deprecated in favor
949
924
of the ``inclusive`` parameter, and will be removed in a future
950
925
version of xarray.
@@ -968,6 +943,7 @@ def cftime_range(
968
943
features of ``pandas.date_range`` (e.g. specifying how the index is
969
944
``closed`` on either side, or whether or not to ``normalize`` the start and
970
945
end bounds); however, there are some notable exceptions:
946
+
971
947
- You cannot specify a ``tz`` (time zone) argument.
972
948
- Start or end dates specified as partial-datetime strings must use the
973
949
`ISO-8601 format <https://en.wikipedia.org/wiki/ISO_8601>`_.
@@ -1186,18 +1162,20 @@ def date_range(
1186
1162
Normalize start/end dates to midnight before generating date range.
1187
1163
name : str, default: None
1188
1164
Name of the resulting index
1189
- closed : {"left", "right"} or None , default: "NO_DEFAULT"
1165
+ closed : {None, "left", "right"}, default: "NO_DEFAULT"
1190
1166
Make the interval closed with respect to the given frequency to the
1191
1167
"left", "right", or both sides (None).
1192
1168
1193
1169
.. deprecated:: 2023.01.1
1194
1170
Following pandas, the `closed` parameter is deprecated in favor
1195
1171
of the `inclusive` parameter, and will be removed in a future
1196
1172
version of xarray.
1197
- inclusive : {None, "both", "neither", "left", "right"}, default None
1173
+
1174
+ inclusive : {None, "both", "neither", "left", "right"}, default: None
1198
1175
Include boundaries; whether to set each bound as closed or open.
1199
1176
1200
1177
.. versionadded:: 2023.01.1
1178
+
1201
1179
calendar : str, default: "standard"
1202
1180
Calendar type for the datetimes.
1203
1181
use_cftime : boolean, optional
0 commit comments