Skip to content

fix overflows in Timestamp.tz_localize near boundaries #19626

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 4 commits into from
Feb 11, 2018

Conversation

jbrockmendel
Copy link
Member

Flesh out docstring for localize_tsobject, add slightly stronger typing.

Closes #12677

@codecov
Copy link

codecov bot commented Feb 10, 2018

Codecov Report

Merging #19626 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19626      +/-   ##
==========================================
- Coverage   91.62%   91.61%   -0.01%     
==========================================
  Files         150      150              
  Lines       48798    48807       +9     
==========================================
+ Hits        44709    44716       +7     
- Misses       4089     4091       +2
Flag Coverage Δ
#multiple 89.99% <ø> (-0.01%) ⬇️
#single 41.73% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/frame.py 97.17% <0%> (-0.26%) ⬇️
pandas/core/dtypes/dtypes.py 96.08% <0%> (ø) ⬆️
pandas/core/groupby.py 92.2% <0%> (+0.07%) ⬆️
pandas/util/testing.py 83.85% <0%> (+0.2%) ⬆️

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 6485a36...1669f38. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

can you add a whatsnew note, small changes. ping on green.

@@ -490,12 +493,37 @@ cdef _TSObject convert_str_to_tsobject(object ts, object tz, object unit,
return convert_to_tsobject(ts, tz, unit, dayfirst, yearfirst)


cdef inline _check_silent_overflows(_TSObject obj):
Copy link
Contributor

Choose a reason for hiding this comment

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

de-privatize. by definition not public if its not in the .pxd

# ----------------------------------------------------------------------
# Localization

cdef inline void _localize_tso(_TSObject obj, object tz):
cdef inline void _localize_tso(_TSObject obj, tzinfo tz):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you de-privatize

@@ -15,12 +15,29 @@
import pandas.util._test_decorators as td

from pandas import Timestamp, NaT
from pandas._libs.tslib import OutOfBoundsDatetime
Copy link
Contributor

Choose a reason for hiding this comment

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

from pandas.errors

@jreback jreback added Bug Timezones Timezone data dtype labels Feb 10, 2018
@jreback jreback added this to the 0.23.0 milestone Feb 10, 2018
@jreback jreback added Error Reporting Incorrect or improved errors from pandas and removed Bug labels Feb 10, 2018
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

more minor comment

if obj.value != NPY_NAT:
# check_silent_overflows needs to run after localize_tso
check_dts_bounds(&obj.dts)
check_silent_overflows(obj)
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to check_overlows

@@ -490,12 +493,37 @@ cdef _TSObject convert_str_to_tsobject(object ts, object tz, object unit,
return convert_to_tsobject(ts, tz, unit, dayfirst, yearfirst)


cdef inline check_silent_overflows(_TSObject obj):
Copy link
Contributor

Choose a reason for hiding this comment

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

rename, add doc-string (just convert your comment)


Returns
-------
(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

None

@jreback
Copy link
Contributor

jreback commented Feb 10, 2018

lgtm. ping ongreen.

@jbrockmendel
Copy link
Member Author

Ping

@jreback jreback merged commit c0e75a5 into pandas-dev:master Feb 11, 2018
@jreback
Copy link
Contributor

jreback commented Feb 11, 2018

thanks

@jreback
Copy link
Contributor

jreback commented Feb 11, 2018

some warnings as a result of this change

pandas/tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::()::test_tz_localize_pushes_out_of_bounds
  /home/travis/build/pandas-dev/pandas/pandas/tests/scalar/timestamp/test_timezones.py:32: RuntimeWarning: overflow encountered in long_scalars
    Timestamp.min.tz_localize('Asia/Tokyo')
  /home/travis/build/pandas-dev/pandas/pandas/tests/scalar/timestamp/test_timezones.py:39: RuntimeWarning: overflow encountered in long_scalars
    Timestamp.max.tz_localize('US/Pacific')

@jbrockmendel jbrockmendel deleted the overflows branch February 11, 2018 21:37
harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
@jreback
Copy link
Contributor

jreback commented Mar 26, 2018

when you have a chance can you look at the warnings above: #19626 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants