(vmin: float, vmax: float, freq: BaseOffset)
| 572 | |
| 573 | @functools.cache |
| 574 | def _daily_finder(vmin: float, vmax: float, freq: BaseOffset) -> np.ndarray: |
| 575 | # error: "BaseOffset" has no attribute "_period_dtype_code" |
| 576 | dtype_code = freq._period_dtype_code # type: ignore[attr-defined] |
| 577 | |
| 578 | periodsperday, periodspermonth, periodsperyear = _get_periods_per_ymd(freq) |
| 579 | |
| 580 | # save this for later usage |
| 581 | vmin_orig = vmin |
| 582 | (vmin, vmax) = (int(vmin), int(vmax)) |
| 583 | span = vmax - vmin + 1 |
| 584 | |
| 585 | with warnings.catch_warnings(): |
| 586 | warnings.filterwarnings( |
| 587 | "ignore", "Period with BDay freq is deprecated", category=FutureWarning |
| 588 | ) |
| 589 | warnings.filterwarnings( |
| 590 | "ignore", r"PeriodDtype\[B\] is deprecated", category=FutureWarning |
| 591 | ) |
| 592 | dates_ = period_range( |
| 593 | start=Period(ordinal=vmin, freq=freq), |
| 594 | end=Period(ordinal=vmax, freq=freq), |
| 595 | freq=freq, |
| 596 | ) |
| 597 | |
| 598 | # Initialize the output |
| 599 | info = np.zeros( |
| 600 | span, dtype=[("val", np.int64), ("maj", bool), ("min", bool), ("fmt", "|S20")] |
| 601 | ) |
| 602 | info["val"][:] = dates_.asi8 |
| 603 | info["fmt"][:] = "" |
| 604 | info["maj"][[0, -1]] = True |
| 605 | # .. and set some shortcuts |
| 606 | info_maj = info["maj"] |
| 607 | info_min = info["min"] |
| 608 | info_fmt = info["fmt"] |
| 609 | |
| 610 | def first_label(label_flags): |
| 611 | if (label_flags[0] == 0) and (label_flags.size > 1) and ((vmin_orig % 1) > 0.0): |
| 612 | return label_flags[1] |
| 613 | else: |
| 614 | return label_flags[0] |
| 615 | |
| 616 | # Case 1. Less than a month |
| 617 | if span <= periodspermonth: |
| 618 | day_start = _period_break(dates_, "day") |
| 619 | month_start = _period_break(dates_, "month") |
| 620 | year_start = _period_break(dates_, "year") |
| 621 | |
| 622 | def _hour_finder(label_interval: int, force_year_start: bool) -> None: |
| 623 | target = dates_.hour |
| 624 | mask = _period_break_mask(dates_, "hour") |
| 625 | info_maj[day_start] = True |
| 626 | info_min[mask & (target % label_interval == 0)] = True |
| 627 | info_fmt[mask & (target % label_interval == 0)] = "%H:%M" |
| 628 | info_fmt[day_start] = "%H:%M\n%d-%b" |
| 629 | info_fmt[year_start] = "%H:%M\n%d-%b\n%Y" |
| 630 | if force_year_start and not has_level_label(year_start, vmin_orig): |
| 631 | info_fmt[first_label(day_start)] = "%H:%M\n%d-%b\n%Y" |
nothing calls this directly
no test coverage detected