-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Datetime dev #87
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 dev #87
Conversation
…riate units In particular, 'now' needs time-like units, and 'today' needs date-like units.
Now it always goes to the more precise unit.
Here I've realized that default 'microsecond' units isn't very good, and would like to make a default 'generic' unit instead.
This allows integers to convert into timedeltas without binding to a default unit, so that later when it's combined with another data type it adopts that type instead of overriding it haphazardly. This makes things generally more intuitive.
…function This cleans up the implementation of arange a lot, and makes the promotion rules behave consistently.
The complexity of the operations desired for business days is such that expressing it as a unit in the datetime doesn't fit naturally. Instead, an API operating on day-based datetimes appears to be a superior approach.
… reductions The default NPY_DATETIME type was still in microseconds, because it wasn't using the NPY_DATETIME_DEFAULTUNIT macro as it should have been. The reduction functions in ufuncs didn't respect the metadata appropriately.
|
||
add_newdoc('numpy.core.multiarray', 'busdaydef', | ||
""" | ||
busdaydef(weekmask='1111100', holidays=None) |
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.
Hmm, the name could be more descriptive, especially as the return object is given the same name. Maybe work calender in there somehow. busdaycal{ender} or some such.
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.
Maybe "busdaycalendar" for the class name, and "busdaycal" for the parameter name in the functions.
* See LICENSE.txt for the license. | ||
*/ | ||
|
||
#define PY_SSIZE_T_CLEAN |
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.
You know, I can't find this macro anywhere except with the #define
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.
It's a signal to Python.h regarding the PyArg_Parse* functions. I've just propagated it from other C files in this case.
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.
Yeah, I found it. It's going to go away somewhere in 3.*
I really like that you have documented a lot of the C functions (although not quit all), it's refreshing. The code looks very nice overall. |
Have you tested what happens with negative times? There are a fair number of integer divisions scattered about... |
Thanks again for the feedback. I've tried to test the negative cases by including dates before and after 1970 in many tests, and focusing the tests on potential problem cases. |
… on Chuck's feedback
It is the integer divisions that concern me since they round towards zero and GCD could be negative, etc. |
The gcd function operates on unsigned ints. I've tried to be pretty careful about the usage of integer division, can you point out the specific cases that are bothering you? |
No, I just know from experience that it can be a problem and wanted to be sure you were aware of it. |
…pecifier One fairly major improvement is that parsing with kind and a size now makes sure there isn't any garbage after the size.
MW: I've removed the asbytes part and changed 'S5' to 'S0' from Derek's original commit.
…and fixing bugs Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from mq/GR-40765 to labs-hpy-port * commit '7fca2aeaec5fe8d86e6259c99eef1afb841a1464': close handles Complete type resolver port to HPy and fixing bugs update scalarmaths slots
feat: Add vpadal_s8
This pull request has all the datetime work that's not merged yet, with tags:
datetime-autounit:
Determine the datetime unit from the form of the input object instead of defaulting to microseconds
datetime-promotion:
Unifying promotion of M8,M8 and M8,m8 operations
datetime-meta:
Adding support for a generic unit to the datetime unit metadata
datetime-arange:
Implementing np.arange support for the datetime type
datetime-bday:
Implementing the proposed business day API.