-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Bug in Timestamp-Timestamp not returning a Timedelta type (GH8865) #8981
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
cc @shoyer was a rabbit-hole! not 100% convinced that the auto-broadcasting strategy will work here, but go for it. |
|
||
# we may be passed reverse ops | ||
if get_timezone(getattr(self,'tzinfo',None)) != get_timezone(other.tz): | ||
raise TypeError("Timestamp subtraction must have the same timezones or no timezones") |
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'm pretty sure timezone comparison is a ValueError... it would be good to be consistent (IMO TypeError is the right choice)
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.
(Pdb) p dt_tz
datetime.datetime(2013, 1, 1, 0, 0, tzinfo=<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>)
(Pdb) p dt
datetime.datetime(2013, 1, 1, 0, 0)
(Pdb) p dt_tz - dt
*** TypeError: TypeError("can't subtract offset-naive and offset-aware datetimes",)
datetime-datetime
has this as a TypeError
(that's why I changed it, originally I had it as a ValueError as well)
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, so maybe you should also change this for comparisons on line 813 above?
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.
fixing this
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 guess its bad when I change from ValueError to TypeError and no tests break :)
It was almost all TypeError, so this is the right move.
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.
actually was a failed test so that is good :)
generally looks pretty good to me! |
@shoyer great! still would love to have you refactor when you have to time to use more array broadcasting stuff. |
…telike-datelike ops with timezones (GH8865)
BUG: Bug in Timestamp-Timestamp not returning a Timedelta type (GH8865)
closes #8865