-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Datetime fixes #83
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
Datetime fixes #83
Conversation
The previous implementation returned the default datetime type in many cases instead of raising an exception. I also changed the hybrid C + Python implementation to be purely in C.
…datetime results There is also a problem with 'O4' and 'O8', which are platform-specific. I changed it to still accept both, but produce a deprecation warning.
…atetime Doing the type promotion rules requires some datetime utility functions which aren't written yet. In the process of setting the stage for those, I've moved a number of functions from descriptor.c to datetime.c and renamed them trying to more descriptively.
The 'den' metadata was always 1, except during construction, so there is no reason for it to exist. The variable is kept in the struct for 1.6 ABI compatibility, however. The datetime_data function used ctypes. Moving the function to C is no more difficult, and a bit cleaner in my opinion.
It turned out pickle roundtripping wasn't being tested, and the changes I did broke that. This restores that functionality and improves some error checking and formatting as suggested by Chuck.
…E_setitem It turns out that the date-time API for converting the npy_datetimestruct to an npy_datetime takes just the NPY_DATETIMEUNIT, not a datetime metadata struct, but I wanted to commit here as a checkpoint before adding what's needed there.
Also added support for parsing events as an integer after the time portion of the string.
The datetime64 is a parameterized type, something which can't be handled with the simple linear list search the ufuncs currently do. This patch adds a function pointer to the end of the ufunc object (should be ABI compatible similar to the metadata addition in 1.4.1), which handles type resolution. This function is set by default to a function which executes the preexisting type resolution functionality.
Also remove some DATETIME ufuncs that didn't make sense (since the datetime type has no zero, these functions still make sense for TIMEDELTA).
I think the right way to handle the logical operations is to reduce them to have just a single loop with all booleans, then use casting to get the inputs to those types. This change requires adding custom type resolution to the reduction ufunc methods as well, which is beyond the scope of datetime.
… more general units
…inting The TimeInteger seemed like the wrong abstraction to me. Timedelta is reasonable as an integer, and in fact if NumPy supported arbitrary unit metadata, Timedelta could be removed and that mechanism used instead. Datetime, however, doesn't represent an integer. Datetime has no zero (barring big bang, God's creation, or some other choice...), something which integers definitely have.
…ring function with several options
This is getting to have quite a few commits. Would it be possible to divide it into uncontroversial/controversial bits? Or maybe into type_fixes/parsing/ufunc_type_conversion, etc.? |
I'm now of the opinion that editing the history in general is not worth the effort except for minor things and if something definitely needs to be split up. Where commits aren't sequentially related within one topic, its because a dependency was encountered and something else needed to be done before I could do what I was working on. Other than that, the way I've done the development is a topic at a time, hopefully my commit messages are reasonable. I could perhaps add tags to the commit to indicate the categories you gave, if you think that would help looking through the commits. I don't think anything I've done here so far is controversial, except perhaps breaking one of the datetime API functions, and changing the datetime scalar type hierarchy since I thought that was breaking the abstraction. |
…bugs Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from mq/GR-40484 to labs-hpy-port * commit 'f53714a39b7683a459c9888d13c4e025e08e3bd3': address comments port few more functions and fixing bugs fixing miss-typed HPyErr_Fromat_p
feat: Add vmovl_s8
As described in my email, this set of patches brings the datetime type a lot closer to working. I thought I'd do a pull request here, and start a fresh branch for further changes while hopefully getting some code reviews from people interested in the datetime type and what needed to change for it to actually work as a parameterized type.