Skip to content

Commit 3bcaea3

Browse files
authored
REF: remove libresolution (#35198)
1 parent 7f50f71 commit 3bcaea3

File tree

7 files changed

+44
-64
lines changed

7 files changed

+44
-64
lines changed

pandas/_libs/tslibs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727

2828
from . import dtypes
2929
from .conversion import localize_pydatetime
30+
from .dtypes import Resolution
3031
from .nattype import NaT, NaTType, iNaT, is_null_datetimelike, nat_strings
3132
from .np_datetime import OutOfBoundsDatetime
3233
from .offsets import BaseOffset, Tick, to_offset
3334
from .period import IncompatibleFrequency, Period
34-
from .resolution import Resolution
3535
from .timedeltas import Timedelta, delta_to_nanoseconds, ints_to_pytimedelta
3636
from .timestamps import Timestamp
3737
from .tzconversion import tz_convert_from_utc_single

pandas/_libs/tslibs/fields.pyx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,46 @@ def build_field_sarray(const int64_t[:] dtindex):
7373
return out
7474

7575

76+
def month_position_check(fields, weekdays):
77+
cdef:
78+
int32_t daysinmonth, y, m, d
79+
bint calendar_end = True
80+
bint business_end = True
81+
bint calendar_start = True
82+
bint business_start = True
83+
bint cal
84+
int32_t[:] years = fields["Y"]
85+
int32_t[:] months = fields["M"]
86+
int32_t[:] days = fields["D"]
87+
88+
for y, m, d, wd in zip(years, months, days, weekdays):
89+
if calendar_start:
90+
calendar_start &= d == 1
91+
if business_start:
92+
business_start &= d == 1 or (d <= 3 and wd == 0)
93+
94+
if calendar_end or business_end:
95+
daysinmonth = get_days_in_month(y, m)
96+
cal = d == daysinmonth
97+
if calendar_end:
98+
calendar_end &= cal
99+
if business_end:
100+
business_end &= cal or (daysinmonth - d < 3 and wd == 4)
101+
elif not calendar_start and not business_start:
102+
break
103+
104+
if calendar_end:
105+
return "ce"
106+
elif business_end:
107+
return "be"
108+
elif calendar_start:
109+
return "cs"
110+
elif business_start:
111+
return "bs"
112+
else:
113+
return None
114+
115+
76116
@cython.wraparound(False)
77117
@cython.boundscheck(False)
78118
def get_date_name_field(const int64_t[:] dtindex, str field, object locale=None):

pandas/_libs/tslibs/resolution.pyx

Lines changed: 0 additions & 53 deletions
This file was deleted.

pandas/core/arrays/datetimes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pandas._libs import lib, tslib
88
from pandas._libs.tslibs import (
99
NaT,
10+
Resolution,
1011
Timestamp,
1112
conversion,
1213
fields,
@@ -15,7 +16,6 @@
1516
ints_to_pydatetime,
1617
is_date_array_normalized,
1718
normalize_i8_timestamps,
18-
resolution as libresolution,
1919
timezones,
2020
to_offset,
2121
tzconversion,
@@ -533,7 +533,7 @@ def is_normalized(self):
533533
return is_date_array_normalized(self.asi8, self.tz)
534534

535535
@property # NB: override with cache_readonly in immutable subclasses
536-
def _resolution_obj(self) -> libresolution.Resolution:
536+
def _resolution_obj(self) -> Resolution:
537537
return get_resolution(self.asi8, self.tz)
538538

539539
# ----------------------------------------------------------------

pandas/tests/tslibs/test_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def test_namespace():
1616
"offsets",
1717
"parsing",
1818
"period",
19-
"resolution",
2019
"strptime",
2120
"vectorized",
2221
"timedeltas",

pandas/tseries/frequencies.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
MONTHS,
1313
int_to_weekday,
1414
)
15-
from pandas._libs.tslibs.fields import build_field_sarray
15+
from pandas._libs.tslibs.fields import build_field_sarray, month_position_check
1616
from pandas._libs.tslibs.offsets import ( # noqa:F401
1717
DateOffset,
1818
Day,
1919
_get_offset,
2020
to_offset,
2121
)
2222
from pandas._libs.tslibs.parsing import get_rule_month
23-
from pandas._libs.tslibs.resolution import month_position_check
2423
from pandas.util._decorators import cache_readonly
2524

2625
from pandas.core.dtypes.common import (

setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ class CheckSDist(sdist_class):
319319
"pandas/_libs/tslibs/conversion.pyx",
320320
"pandas/_libs/tslibs/fields.pyx",
321321
"pandas/_libs/tslibs/offsets.pyx",
322-
"pandas/_libs/tslibs/resolution.pyx",
323322
"pandas/_libs/tslibs/parsing.pyx",
324323
"pandas/_libs/tslibs/tzconversion.pyx",
325324
"pandas/_libs/tslibs/vectorized.pyx",
@@ -639,10 +638,6 @@ def srcpath(name=None, suffix=".pyx", subdir="src"):
639638
"depends": tseries_depends,
640639
"sources": ["pandas/_libs/tslibs/src/datetime/np_datetime.c"],
641640
},
642-
"_libs.tslibs.resolution": {
643-
"pyxfile": "_libs/tslibs/resolution",
644-
"depends": tseries_depends,
645-
},
646641
"_libs.tslibs.strptime": {
647642
"pyxfile": "_libs/tslibs/strptime",
648643
"depends": tseries_depends,

0 commit comments

Comments
 (0)