Skip to content
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

BUG: underflow on Timestamp creation #14433

Merged
merged 3 commits into from
Oct 20, 2016

Conversation

chris-b1
Copy link
Contributor

@chris-b1 chris-b1 commented Oct 16, 2016

@chris-b1 chris-b1 added Bug Datetime Datetime data dtype labels Oct 16, 2016
@chris-b1 chris-b1 added this to the 0.19.1 milestone Oct 16, 2016
cdef extern from "headers/stdint.h":
enum: INT64_MAX
enum: INT64_MIN

Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't these be imported from the numpy headers? for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is how we do it in lib.pyx, but agreed it probably makes more sense to pull it from the numpy headers.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok no big deal
ideally should be consistent across the code
maybe just import into util.pxd and use from there?

cdef int64_t _NS_LOWER_BOUND = -9223285636854775000LL
cdef int64_t _NS_UPPER_BOUND = 9223372036854775807LL
# INT64_MIN is reserved for NaT
cdef int64_t _NS_LOWER_BOUND = INT64_MIN + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

why change this?
iirc some platforms don't play nice with this definition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old lower bound was higher than it needed to be, because of this issue; although we didn't actually enforce it everywhere. Upper bound is the same.

I can go back to hardcoded numbers, just thought the defined constants were clearer - I assumed INT64_MAX is platform independent (could be wrong)

Copy link
Contributor

Choose a reason for hiding this comment

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

it's fine
i don't know why these were hard coded in the first place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On further look, I'll change the lower bound back - in our compat with python datetime we assume in several places that the min value has a 0 nanosecond unit - I think it could be worked around, but fairly invasive for another 800 ns of span.

@codecov-io
Copy link

codecov-io commented Oct 16, 2016

Current coverage is 85.26% (diff: 100%)

Merging #14433 into master will increase coverage by <.01%

@@             master     #14433   diff @@
==========================================
  Files           140        140          
  Lines         50640      50640          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43175      43176     +1   
+ Misses         7465       7464     -1   
  Partials          0          0          

Powered by Codecov. Last update 921ce47...4b7674c

@jreback
Copy link
Contributor

jreback commented Oct 19, 2016

lgtm. Push again though (you might need to git commmit --all --amend -C amend to generate a new has. Want to make sure that appveyor is working. I just turned it back on (was set to old pydata/pandas repo)

@jreback
Copy link
Contributor

jreback commented Oct 20, 2016

lgtm. rebase and merge.

@chris-b1 chris-b1 force-pushed the timestamp-underflow branch from a180a1a to 4b7674c Compare October 20, 2016 11:20
@chris-b1 chris-b1 merged commit 65362aa into pandas-dev:master Oct 20, 2016
tworec pushed a commit to RTBHOUSE/pandas that referenced this pull request Oct 21, 2016
* BUG: underflow on Timestamp creation

* undo change to lower bound

* change lower bound; but keep rounding to us
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this pull request Nov 2, 2016
* BUG: underflow on Timestamp creation

* undo change to lower bound

* change lower bound; but keep rounding to us

(cherry picked from commit 65362aa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent behavior in Timestamp for large negative values
3 participants