Skip to content

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

Merged
merged 5 commits into from
Jul 2, 2018

Conversation

jbrockmendel
Copy link
Member

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.

@codecov
Copy link

codecov bot commented Jul 1, 2018

Codecov Report

Merging #21691 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 90.28% <100%> (-0.01%) ⬇️
#single 41.9% <15.38%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/tseries/offsets.py 97.1% <100%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad76ffc...3e81f57. Read the comment docs.

@@ -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
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

@jreback jreback Jul 2, 2018

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

@@ -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.
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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

@@ -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.
Copy link
Contributor

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

@jreback jreback added Frequency DateOffsets Timezones Timezone data dtype Clean labels Jul 2, 2018
@jreback jreback added this to the 0.24.0 milestone Jul 2, 2018
@jreback jreback merged commit be14333 into pandas-dev:master Jul 2, 2018
@jreback
Copy link
Contributor

jreback commented Jul 2, 2018

thanks @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Frequency DateOffsets Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants