-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Add fix for hashing timestamps with folds #44282
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
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
|
||
def test_hash_timestamp_with_fold(): | ||
# see gh-33931 | ||
america_chicago = dateutil.tz.gettz("America/Chicago") |
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.
Could you use pytest.mark.parameterize
over the timezone and TImestamp inputs?
@@ -166,3 +166,24 @@ def test_maybe_get_tz_offset_only(): | |||
|
|||
tz = timezones.maybe_get_tz("UTC-02:45") | |||
assert tz == timezone(-timedelta(hours=2, minutes=45)) | |||
|
|||
|
|||
def test_hash_timestamp_with_fold(): |
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.
try tests.scalar.timestamp.test_timestamp, there's another test with "hash" in the name that this can go right next to
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.
can you add a whatsnew note abou this 1.4., datetime bug fix section.
also we'd like to assure that this isn't impacting perf very much. if you can run the datetime asv's would be great
14083f5
to
c6400d6
Compare
@jreback I don't see an asv set datetime specifically, so I tried to run the all of the ones for
|
There aren't any asvs that specifically hit this. If you wanted to add one, it would go in benchmarks.tslibs.timestamp. Ideally in TimestampOps, but i dont know if it the (an asv for this is likely overkill) |
can you add the test here: #40817 as well. ping on green for merge |
Add unit test for reindexing with fold
@jreback Sounds good, I've added the reindex unit test and mentioned it in whatsnew |
@jreback Any more thoughts? |
thanks @jonwiggins very nice! |
Edit:
#42305 (comment)
This comment identifies the problem as being upstream in datetime's construction of timestamps which fails during some DST changes.
The datetime hash function then being used tries to unset the fold representing the DST change, (https://github.com/python/cpython/blob/main/Lib/datetime.py#L2117). But it does this using the datetime replace function - this change fixes that problem by removing the fold prior to calling the datetime hash function using timestamp's replace function instead.