8000 Datetime dev 2 by mwiebe · Pull Request #93 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Datetime dev 2 #93

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 14 commits into from
Jun 22, 2011
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: datetime-meta: Remove 'events' from the datetime metadata
The events don't fit well within the datetime, causing many special
cases and complicating the datetime code. A better way to proceed,
which received approval from Travis with regard to the reason events
were introduced in the first place, is to do the following:

* Generalize the structured arrays so they work with ufuncs
* Either use NPY_UBYTE, or introduce a new integer modulo N type
* The structured dtype [('date', 'M8[D]'), ('event', 'u8')], then
  will operate identically to the design of events in datetime.

These other changes will have much use elsewhere as well.
  • Loading branch information
Mark Wiebe committed Jun 17, 2011
commit cb45456d046f86d009e1a4dbdc73d893be6b3ce6
6 changes: 3 additions & 3 deletions numpy/core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,9 @@ typedef struct {
NPY_DATETIMEUNIT base;
int num;
/*
* 'den' is unused, kept here for ABI compatibility with 1.6.
* 'den' and 'events are unused, kept here for ABI
* compatibility with 1.6.
*
* TODO: Remove for 2.0.
*/
int den;
Expand All @@ -732,14 +734,12 @@ typedef struct {
typedef struct {
npy_int64 year;
npy_int32 month, day, hour, min, sec, us, ps, as;
npy_int32 event;
} npy_datetimestruct;

/* TO BE REMOVED - NOT USED INTERNALLY. */
typedef struct {
npy_int64 day;
npy_int32 sec, us, ps, as;
npy_int32 event;
} npy_timedeltastruct;

/* TO BE REMOVED - NOT USED INTERNALLY. */
Expand Down
8 changes: 2 additions & 6 deletions numpy/core/src/multiarray/_datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ compute_datetime_metadata_greatest_common_divisor_capsule(

/*
* Computes the conversion factor to convert data with 'src_meta' metadata
* into data with 'dst_meta' metadata, not taking into account the events.
*
* To convert a npy_datetime or npy_timedelta, first the event number needs
* to be divided away, then it needs to be scaled by num/denom, and
* finally the event number can be added back in.
* into data with 'dst_meta' metadata.
*
* If overflow occurs, both out_num and out_denom are set to 0, but
* no error is set.
Expand Down Expand Up @@ -231,7 +227,7 @@ convert_pyobject_to_datetime_metadata(PyObject *obj,
* 'ret' is a PyUString containing the datetime string, and this
* function appends the metadata string to it.
*
* If 'skip_brackets' is true, skips the '[]' when events == 1.
* If 'skip_brackets' is true, skips the '[]'.
*
* This function steals the reference 'ret'
*/
Expand Down
1 change: 0 additions & 1 deletion numpy/core/src/multiarray/arraytypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -3438,7 +3438,6 @@ _init_datetime_descr(PyArray_Descr *descr)
dt_data = PyArray_malloc(sizeof(PyArray_DatetimeMetaData));
dt_data->base = NPY_DATETIME_DEFAULTUNIT;
dt_data->num = 1;
dt_data->events = 1;

/* FIXME
* There is no error check here and no way to indicate an error
Expand Down
Loading
0