-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
move and de-privatize _localize_pydatetime, move shift_day to liboffsets #21691
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21691 +/- ##
==========================================
- Coverage 91.9% 91.9% -0.01%
==========================================
Files 154 154
Lines 49659 49652 -7
==========================================
- Hits 45640 45633 -7
Misses 4019 4019
Continue to review full report at Codecov.
|
pandas/_libs/tslib.pyx
Outdated
@@ -54,6 +54,7 @@ from tslibs.nattype cimport checknull_with_nat, NPY_NAT | |||
from tslibs.timestamps cimport (create_timestamp_from_ts, | |||
_NS_UPPER_BOUND, _NS_LOWER_BOUND) | |||
from tslibs.timestamps import Timestamp | |||
from tslibs.offsets import localize_pydatetime # noqa:F841 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be ok with not doing this import and changing the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the current set of PRs I'm going to pitch an idea to 1) finish off tslib
and 2) expose selected functions/classes in tslibs.__init__
. I'd rather avoid futzing with imports until then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok that's fine, though in this case its simple enough to remove, so should just do it, 1 less thing to do later
pandas/_libs/tslibs/offsets.pyx
Outdated
@@ -494,6 +498,58 @@ class BaseOffset(_BaseOffset): | |||
# ---------------------------------------------------------------------- | |||
# RelativeDelta Arithmetic | |||
|
|||
cpdef inline datetime localize_pydatetime(datetime dt, object tz): | |||
""" | |||
Take a datetime/Timestamp in UTC and localizes to timezone tz. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be in timezones.pyx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keeping timezones
"naive" of datetime
/Timestamp
implementations. It would be a decent fit with conversion
though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's do that
pandas/_libs/tslibs/offsets.pyx
Outdated
@@ -494,6 +498,58 @@ class BaseOffset(_BaseOffset): | |||
# ---------------------------------------------------------------------- | |||
# RelativeDelta Arithmetic | |||
|
|||
cpdef inline datetime localize_pydatetime(datetime dt, object tz): | |||
""" | |||
Take a datetime/Timestamp in UTC and localizes to timezone tz. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's do that
thanks @jbrockmendel |
The only non-test place where tslib._localize_pydatetime is used is in tseries.offsets. This moves that func to liboffsets, de-privatizes it, and moves tseris.offsets.shift_day up to liboffsets.
To avoid import proliferation this keeps localize_pydatetime in the tslib namespace so the tests can get at it.
Adds some typing to localize_pydatetime and fleshes out the docstring.