Skip to content

REF: remove libresolution #35198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

from . import dtypes
from .conversion import localize_pydatetime
from .dtypes import Resolution
from .nattype import NaT, NaTType, iNaT, is_null_datetimelike, nat_strings
from .np_datetime import OutOfBoundsDatetime
from .offsets import BaseOffset, Tick, to_offset
from .period import IncompatibleFrequency, Period
from .resolution import Resolution
from .timedeltas import Timedelta, delta_to_nanoseconds, ints_to_pytimedelta
from .timestamps import Timestamp
from .tzconversion import tz_convert_from_utc_single
Expand Down
40 changes: 40 additions & 0 deletions pandas/_libs/tslibs/fields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,46 @@ def build_field_sarray(const int64_t[:] dtindex):
return out


def month_position_check(fields, weekdays):
cdef:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you can add a doc-string / types at some point

int32_t daysinmonth, y, m, d
bint calendar_end = True
bint business_end = True
bint calendar_start = True
bint business_start = True
bint cal
int32_t[:] years = fields["Y"]
int32_t[:] months = fields["M"]
int32_t[:] days = fields["D"]

for y, m, d, wd in zip(years, months, days, weekdays):
if calendar_start:
calendar_start &= d == 1
if business_start:
business_start &= d == 1 or (d <= 3 and wd == 0)

if calendar_end or business_end:
daysinmonth = get_days_in_month(y, m)
cal = d == daysinmonth
if calendar_end:
calendar_end &= cal
if business_end:
business_end &= cal or (daysinmonth - d < 3 and wd == 4)
elif not calendar_start and not business_start:
break

if calendar_end:
return "ce"
elif business_end:
return "be"
elif calendar_start:
return "cs"
elif business_start:
return "bs"
else:
return None


@cython.wraparound(False)
@cython.boundscheck(False)
def get_date_name_field(const int64_t[:] dtindex, str field, object locale=None):
Expand Down
53 changes: 0 additions & 53 deletions pandas/_libs/tslibs/resolution.pyx

This file was deleted.

4 changes: 2 additions & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pandas._libs import lib, tslib
from pandas._libs.tslibs import (
NaT,
Resolution,
Timestamp,
conversion,
fields,
Expand All @@ -15,7 +16,6 @@
ints_to_pydatetime,
is_date_array_normalized,
normalize_i8_timestamps,
resolution as libresolution,
timezones,
to_offset,
tzconversion,
Expand Down Expand Up @@ -533,7 +533,7 @@ def is_normalized(self):
return is_date_array_normalized(self.asi8, self.tz)

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

# ----------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/tslibs/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def test_namespace():
"offsets",
"parsing",
"period",
"resolution",
"strptime",
"vectorized",
"timedeltas",
Expand Down
3 changes: 1 addition & 2 deletions pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
MONTHS,
int_to_weekday,
)
from pandas._libs.tslibs.fields import build_field_sarray
from pandas._libs.tslibs.fields import build_field_sarray, month_position_check
from pandas._libs.tslibs.offsets import ( # noqa:F401
DateOffset,
Day,
_get_offset,
to_offset,
)
from pandas._libs.tslibs.parsing import get_rule_month
from pandas._libs.tslibs.resolution import month_position_check
from pandas.util._decorators import cache_readonly

from pandas.core.dtypes.common import (
Expand Down
5 changes: 0 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ class CheckSDist(sdist_class):
"pandas/_libs/tslibs/conversion.pyx",
"pandas/_libs/tslibs/fields.pyx",
"pandas/_libs/tslibs/offsets.pyx",
"pandas/_libs/tslibs/resolution.pyx",
"pandas/_libs/tslibs/parsing.pyx",
"pandas/_libs/tslibs/tzconversion.pyx",
"pandas/_libs/tslibs/vectorized.pyx",
Expand Down Expand Up @@ -639,10 +638,6 @@ def srcpath(name=None, suffix=".pyx", subdir="src"):
"depends": tseries_depends,
"sources": ["pandas/_libs/tslibs/src/datetime/np_datetime.c"],
},
"_libs.tslibs.resolution": {
"pyxfile": "_libs/tslibs/resolution",
"depends": tseries_depends,
},
"_libs.tslibs.strptime": {
"pyxfile": "_libs/tslibs/strptime",
"depends": tseries_depends,
Expand Down