|
13 | 13 | Any,
|
14 | 14 | cast,
|
15 | 15 | )
|
| 16 | +import warnings |
16 | 17 |
|
17 | 18 | import matplotlib.dates as mdates
|
18 | 19 | from matplotlib.ticker import (
|
@@ -239,18 +240,29 @@ def _convert_1d(values, units, axis):
|
239 | 240 | if not hasattr(axis, "freq"):
|
240 | 241 | raise TypeError("Axis must have `freq` set to convert to Periods")
|
241 | 242 | valid_types = (str, datetime, Period, pydt.date, pydt.time, np.datetime64)
|
242 |
| - if isinstance(values, valid_types) or is_integer(values) or is_float(values): |
243 |
| - return get_datevalue(values, axis.freq) |
244 |
| - elif isinstance(values, PeriodIndex): |
245 |
| - return values.asfreq(axis.freq).asi8 |
246 |
| - elif isinstance(values, Index): |
247 |
| - return values.map(lambda x: get_datevalue(x, axis.freq)) |
248 |
| - elif lib.infer_dtype(values, skipna=False) == "period": |
249 |
| - # https://github.com/pandas-dev/pandas/issues/24304 |
250 |
| - # convert ndarray[period] -> PeriodIndex |
251 |
| - return PeriodIndex(values, freq=axis.freq).asi8 |
252 |
| - elif isinstance(values, (list, tuple, np.ndarray, Index)): |
253 |
| - return [get_datevalue(x, axis.freq) for x in values] |
| 243 | + with warnings.catch_warnings(): |
| 244 | + warnings.filterwarnings( |
| 245 | + "ignore", "Period with BDay freq is deprecated", category=FutureWarning |
| 246 | + ) |
| 247 | + warnings.filterwarnings( |
| 248 | + "ignore", r"PeriodDtype\[B\] is deprecated", category=FutureWarning |
| 249 | + ) |
| 250 | + if ( |
| 251 | + isinstance(values, valid_types) |
| 252 | + or is_integer(values) |
| 253 | + or is_float(values) |
| 254 | + ): |
| 255 | + return get_datevalue(values, axis.freq) |
| 256 | + elif isinstance(values, PeriodIndex): |
| 257 | + return values.asfreq(axis.freq).asi8 |
| 258 | + elif isinstance(values, Index): |
| 259 | + return values.map(lambda x: get_datevalue(x, axis.freq)) |
| 260 | + elif lib.infer_dtype(values, skipna=False) == "period": |
| 261 | + # https://github.com/pandas-dev/pandas/issues/24304 |
| 262 | + # convert ndarray[period] -> PeriodIndex |
| 263 | + return PeriodIndex(values, freq=axis.freq).asi8 |
| 264 | + elif isinstance(values, (list, tuple, np.ndarray, Index)): |
| 265 | + return [get_datevalue(x, axis.freq) for x in values] |
254 | 266 | return values
|
255 | 267 |
|
256 | 268 |
|
@@ -575,11 +587,18 @@ def _daily_finder(vmin, vmax, freq: BaseOffset) -> np.ndarray:
|
575 | 587 | (vmin, vmax) = (int(vmin), int(vmax))
|
576 | 588 | span = vmax - vmin + 1
|
577 | 589 |
|
578 |
| - dates_ = period_range( |
579 |
| - start=Period(ordinal=vmin, freq=freq), |
580 |
| - end=Period(ordinal=vmax, freq=freq), |
581 |
| - freq=freq, |
582 |
| - ) |
| 590 | + with warnings.catch_warnings(): |
| 591 | + warnings.filterwarnings( |
| 592 | + "ignore", "Period with BDay freq is deprecated", category=FutureWarning |
| 593 | + ) |
| 594 | + warnings.filterwarnings( |
| 595 | + "ignore", r"PeriodDtype\[B\] is deprecated", category=FutureWarning |
| 596 | + ) |
| 597 | + dates_ = period_range( |
| 598 | + start=Period(ordinal=vmin, freq=freq), |
| 599 | + end=Period(ordinal=vmax, freq=freq), |
| 600 | + freq=freq, |
| 601 | + ) |
583 | 602 |
|
584 | 603 | # Initialize the output
|
585 | 604 | info = np.zeros(
|
@@ -1072,7 +1091,13 @@ def __call__(self, x, pos: int = 0) -> str:
|
1072 | 1091 | fmt = self.formatdict.pop(x, "")
|
1073 | 1092 | if isinstance(fmt, np.bytes_):
|
1074 | 1093 | fmt = fmt.decode("utf-8")
|
1075 |
| - period = Period(ordinal=int(x), freq=self.freq) |
| 1094 | + with warnings.catch_warnings(): |
| 1095 | + warnings.filterwarnings( |
| 1096 | + "ignore", |
| 1097 | + "Period with BDay freq is deprecated", |
| 1098 | + category=FutureWarning, |
| 1099 | + ) |
| 1100 | + period = Period(ordinal=int(x), freq=self.freq) |
1076 | 1101 | assert isinstance(period, Period)
|
1077 | 1102 | return period.strftime(fmt)
|
1078 | 1103 |
|
|
0 commit comments