Repository navigation
BUG: timedelta64 now accepts NumPy ints - #11852
Conversation
|
Testing failure Looks like travis messing up. Grrr. |
|
They may have changed their testing environment, although why it only affects the one test escapes me. |
|
Yeah, not sure what is going on with that test; restarting certainly doesn't seem helpful. |
|
I'm going to try closing and reopening to see if that makes a difference. |
There was a problem hiding this comment.
Can't this be done as else if with the error return alone in an else section?
|
Looks like the test is missing a path. |
bdc3d11 to
4a71482
Compare
|
I tried to address the revisions & rebase on latest master for ci issue; let's see what it says I guess. |
I'm not convinced I actually fixed it, it may be that there is a badly configured machine out there and we are having a lucky streak of not running on it. |
| np.timedelta64(123, unit)) | ||
| else: | ||
| assert_equal(np.timedelta64(np.int64(123)), | ||
| np.timedelta64(123)) |
There was a problem hiding this comment.
I'm not sure allowing default units to be implied is a good idea. Is there precedent for this in datetime64?
There was a problem hiding this comment.
Can you clarify? np.timedelta64(123) already casts to the default m8 in the master branch; the code to handle a np.int64(123) in the same way is just duplicating that logic for another kind of integer input--it is an actual copy-paste of code for regular Python integer handling farther up.
|
One issue may simply be that we're hesitant to bake in new support for things in datetime64; I've tried to hold off on any more datetime64 PRs beyond the initial batch from a few weeks ago. |
| *out = NPY_DATETIME_NAT; | ||
| return 0; | ||
| } | ||
| else if (PyArray_IsScalar(obj, Integer)) { |
There was a problem hiding this comment.
Move this branch up, next to the branch handling "raw integers" on line 2661?
There was a problem hiding this comment.
This causes test failures in my hands -- I'm guessing other types of inputs get drawn in to the branch too early if moved up there.
There was a problem hiding this comment.
Hmm. I bet this is due to #10685.
OK then, this looks good to me then.
|
thanks @tylerjereddy ! |
|
@tylerjereddy @shoyer I don't see this pull request in the changelogs. I'm currently running with v1.15.4 and it fails if I attempt to convert a int64 into a timedelta. is this possible? Thanks in advance |
|
I don't think this was backported to the NumPy 1.15 branch. You'll need to wait for NumPy 1.16 (maybe only a few weeks?) |
|
@shoyer thanks for the fast response. I thought It should be there because it was merged prior to v1.15.3 but I have no problem to wait, I'll just wrap it with |
Fixes #7617
I should (probably) add more tests & maybe account for the duplication logic (another branch of the C function adjusted here uses that block too) by abstracting to a "helper" function.