Skip to content

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

Merged
merged 34 commits into from
Jun 16, 2011
Merged

Datetime dev #87

merged 34 commits into from
Jun 16, 2011

Conversation

mwiebe
Copy link
Member

@mwiebe mwiebe commented Jun 9, 2011

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.

Mark Wiebe added 25 commits June 9, 2011 12:03
…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)
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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.*

@charris
Copy link
Member

charris commented Jun 16, 2011

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.

@charris
Copy link
Member

charris commented Jun 16, 2011

Have you tested what happens with negative times? There are a fair number of integer divisions scattered about...

@charris charris closed this Jun 16, 2011
@charris charris reopened this Jun 16, 2011
@mwiebe
Copy link
Member Author

mwiebe commented Jun 16, 2011

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.

@charris
Copy link
Member

charris commented Jun 16, 2011

It is the integer divisions that concern me since they round towards zero and GCD could be negative, etc.

@mwiebe
Copy link
Member Author

mwiebe commented Jun 16, 2011

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?

@charris
Copy link
Member

charris commented Jun 16, 2011

No, I just know from experience that it can be a problem and wanted to be sure you were aware of it.

Mark Wiebe and others added 5 commits June 16, 2011 14:22
…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.
@mwiebe mwiebe merged commit 2d7d59a into numpy:master Jun 16, 2011
fangerer pushed a commit to hpyproject/numpy-hpy that referenced this pull request Dec 12, 2022
…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
luyahan pushed a commit to plctlab/numpy that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants